我正在使用SWRevealViewController构建侧边栏菜单。
当从菜单(UITableView)中选择元素时,我有那种方法来选择合适的控制器。情节标识符/名称在情节提要中进行配置。
- (void) prepareForSegue: (UIStoryboardSegue *) segue sender: (id) sender
{
NSLog(@"Tapped");
// Set the title of navigation bar by using the menu items
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
UINavigationController *destViewController = (UINavigationController*)segue.destinationViewController;
destViewController.title = [[_menuItems objectAtIndex:indexPath.row] capitalizedString];
// Set the photo if it navigates to the PhotoView
if ([segue.identifier isEqualToString:@"showToday"]) {
[segue destinationViewController];
}
if ([segue.identifier isEqualToString:@"showCountries"]) {
[segue destinationViewController];
}
if ( [segue isKindOfClass: [SWRevealViewControllerSegue class]] ) {
SWRevealViewControllerSegue *swSegue = (SWRevealViewControllerSegue*) segue;
swSegue.performBlock = ^(SWRevealViewControllerSegue* rvc_segue, UIViewController* svc, UIViewController* dvc) {
UINavigationController* navController = (UINavigationController*)self.revealViewController.frontViewController;
[navController setViewControllers: @[dvc] animated: NO ];
[self.revealViewController setFrontViewPosition: FrontViewPositionLeft animated: YES];
};
}
}
但是从侧栏菜单中选择一个项目时没有任何反应,这可能是问题所在吗?谢谢您的帮助。
最佳答案
我的错是选择“附件动作”而不是“选择选择”“显示视图控制器”。
关于ios - prepareForSegue从未调用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/17506882/