开发者

Load a particular NIB based on tableview selection

开发者 https://www.devze.com 2023-01-08 08:18 出处:网络
I have an initial table view that I created as the initial menu within my app. Obviously each option will access something different including NIBs. Part of the constants for the menu options is the N

I have an initial table view that I created as the initial menu within my app. Obviously each option will access something different including NIBs. Part of the constants for the menu options is the NIB. When each option is pulled from a PLIST, I also include which NIB I would like to be called upon.

Am I missing something or am I just going the wrong way entirely?

Right now a selection does nothing.

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

NSMutableString *targetnib = [[self.menuoptions objectAtIndex:indexPath.row] objectForKey:NIB_KEY];
if (targetnib == @"HospitalDirectoryViewController") {
    HospitalDirectoryViewController *hospitalDirectoryViewController = [[HospitalDirectoryViewController alloc] initWithNibName:@"HospitalDirectoryViewController" bundle:nil];
    // ...
    // Pass the selected object to the new view controller.
    [self.navigationController pushViewController:hospitalDirectoryViewController animated:YES];
    [hospitalDirectoryViewController release];
}
if (targetnib == @"PhysicianDirectoryViewController") {
PhysicianDirectoryViewController *physicianDirectoryViewController = [[PhysicianDirectoryViewController alloc] initWithNibName:@"PhysicianDirectoryViewController" bundle:nil];
 // ...
 // Pass the selected object to the new view controller.
 [self.navigationController pushViewController:physicianDirectoryViewController animated开发者_Go百科:YES];
 [physicianDirectoryViewController release];
}

}


Try using [targetnib isEqualToString: @"TheNibName"]. In your posted code, you're comparing pointers, not the text.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号