Processing TableViewController, you can go to either of two controllers, one of which is UIWebViewController

Noob when developing iOS. This is just a matter of feasibility. I wanted to see if it is possible to have a TableViewController and, based on the type of data that is inserted into the cell, does it have a pushViewController between two different controllers.

For example, for example, we have locations and people who can be returned as search results, and we either want to make pushViewController using ProfileController or LocationController? It would be important if there was one of the UIWebView controllers?

thank

EDIT 1 I assume I'm looking for a way to tell if a TableView cell responds to a specific message like this question in Objective-C, given an identifier, how can I determine which type of object is pointing to? and determines which UIViewController should click.

0
source share
1 answer

If you want to “click” another view controller, your table view controller must be built into the UINavigationController. Then there are two ways to handle clicking a new view controller when selecting a row:

(iOS < 5.0) , -tableView:didSelectRowAtIndexPath: ( ). , , indexPath, , , , . :

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    UIViewController *nextVC;
    if (indexPath.section == 0) {
        nextVC = [[ProfileController alloc] init];
        // configure nextVC as needed
    } else {
        nextVC = [[LocationController alloc] init];
        // configure nextVC as needed
    }
    [self.navigationController pushViewController:nextVC animated:YES];
}

(iOS 5.0+) - IB -prepareForSegue:sender:... . . -tableView:didSelectRowAtIndexPath:, , performSegueWithIdentifier: , . :

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.section == 0) {
        [self peformSegueWithIdentifier:@"showProfile"];
    } else {
        [self peformSegueWithIdentifier:@"showLocation"];
    }
}

, , -prepareForSegue:sender:.

UIWebViewController... , UIWebView.

0

All Articles