我正在尝试将ZUUIRevealController实施到我的项目中,此应用程序使用带有3个选项卡的UITabBarController。
我多次进行了截屏和示例代码,但我不知道为什么
[self.navigationController.parentViewController respondsToSelector:@selector(revealToggle)]
仅以假回应。
在我的appdelegate中,我只创建一个简单的UITabBarController并添加为rootViewController:
UITableViewController *activityViewController = [[[ActivityViewController alloc] initWithNibName:@"ActivityViewController" bundle:nil] autorelease];
UIViewController *agendaViewController = [[[AgendaViewController alloc] initWithNibName:@"AgendaViewController" bundle:nil] autorelease];
UIViewController *settingsViewController = [[[SettingsViewController alloc] initWithNibName:@"SettingsViewController" bundle:nil] autorelease];
UINavigationController *activityNavController = [[[UINavigationController alloc] initWithRootViewController:activityViewController] autorelease];
UINavigationController *agendaNavController = [[[UINavigationController alloc] initWithRootViewController:agendaViewController] autorelease];
UINavigationController *settingsNavController = [[[UINavigationController alloc] initWithRootViewController:settingsViewController] autorelease];
self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:activityNavController, agendaNavController, settingsNavController, nil];
SortViewController *sortViewController = [[SortViewController alloc] init];
ZUUIRevealController *revealController = [[ZUUIRevealController alloc] initWithFrontViewController:self.tabBarController rearViewController:sortViewController];
[sortViewController release];
//self.window.rootViewController = self.tabBarController;
self.window.rootViewController = revealController;
[revealController release];
[self.window makeKeyAndVisible];
但是当我在ActivityViewController中进行检查时,我只会得到false
if([self.tabBarController.parentViewController respondsToSelector:@selector(revealToggle)])
{
NSLog(@"YAY");
}
else
{
NSLog(@"WRONG");
}
在截屏视频中看起来是如此简单,但是看起来我缺少了一些东西。
ZUUIRevealController:https://github.com/pkluz/ZUUIRevealController
最佳答案
只需在检查:
时将respondsToSelector:
放在if语句中
if([self.tabBarController.parentViewController respondsToSelector:@selector(revealToggle:)])
关于iphone - 使用UITabBarController而不是UINavigationController的ZUUIRevealController,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/10446972/