我一直在搜索堆栈溢出,我无法解决问题,我在AppDelegate.m
中有以下代码:
UINavigationController *navigationController = (UINavigationController *)self.window.rootViewController;
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:storyboard bundle: nil];
InternetConnectionViewController *controller = (InternetConnectionViewController*)[mainStoryboard instantiateViewControllerWithIdentifier: noInternet];
[navigationController pushViewController:controller animated:YES];
但是给我一个错误......:
Uncaught exception: -[CustomSplitViewController pushViewController:animated:]: unrecognized selector sent to instance 0x17884860
2016-06-16 02:34:14.896 --[3340:1197655] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CustomSplitViewController pushViewController:animated:]: unrecognized selector sent to instance 0x17884860'
*** First throw call stack:
(0x20c6b91b 0x20406e17 0x20c712b5 0x20c6eee1 0x20b9a238 0x23005d 0xb1cb7f 0xb1cb6b 0xb21655 0x20c2db6d 0x20c2c067 0x20b7b229 0x20b7b015 0x2216bac9 0x2524d189 0x18abdb 0x20823873)
libc++abi.dylib: terminating with uncaught exception of type NSException
warning: could not load any Objective-C class information from the dyld shared cache. This will significantly reduce the quality of type information available.
编辑 - 更新 我设法实现它,现在正在工作......但是当我尝试这样做时:
UINavigationController *navigationController = self.navigationController;
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle: nil];
HomeViewController *controller = (HomeViewController*)[mainStoryboard instantiateViewControllerWithIdentifier: viewC];
[navigationController pushViewController:controller animated:YES];
在InternetViewController中,它给出了以下错误:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UINavigationController setPanGestureEnabled:]: unrecognized selector sent to instance 0x16942a00'
答案 0 :(得分:1)
在AppDelegate.h文件中创建属性
@property (strong, nonatomic) UINavigationController *navController;
然后
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
MainTabBarController *mainTabbarController = [storyboard instantiateViewControllerWithIdentifier:@"MainTabbar"];
self.navController = [[UINavigationController alloc] initWithRootViewController:mainTabbarController];
self.window.rootViewController = self.navController;
[self.window makeKeyAndVisible];
答案 1 :(得分:0)
试试这个
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:storyboard bundle: nil];
InternetConnectionViewController *controller = (InternetConnectionViewController*)[mainStoryboard instantiateViewControllerWithIdentifier: noInternet];
UINavigationController *navObj = [[UINavigationController alloc]initWithRootViewController:controller];
self.window.rootViewController = navObj;
希望这有帮助!