MrGracket MrGracket - 8 months ago 192
iOS Question

PushingViewController in AppDelegate unrecognized selector to instance

I've been searching arround stackoverflow and I am not able to fix my problem, I have the following code in my


UINavigationController *navigationController = (UINavigationController *)self.window.rootViewController;
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:storyboard bundle: nil];
InternetConnectionViewController *controller = (InternetConnectionViewController*)[mainStoryboard instantiateViewControllerWithIdentifier: noInternet];
[navigationController pushViewController:controller animated:YES];

But is giving me an error...:

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.

I manage to achieve it and now is working... but when I try to do this:

UINavigationController *navigationController = self.navigationController;
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle: nil];
HomeViewController *controller = (HomeViewController*)[mainStoryboard instantiateViewControllerWithIdentifier: viewC];
[navigationController pushViewController:controller animated:YES];

in the InternetViewController it gives me the following error:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UINavigationController setPanGestureEnabled:]: unrecognized selector sent to instance 0x16942a00'


Create property in AppDelegate.h file

@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];