gpt4 book ai didi

ios - AppDelegate 中的 PushingViewController 无法识别的选择器实例

转载 作者:行者123 更新时间:2023-11-29 00:53:32 27 4
gpt4 key购买 nike

我一直在 stackoverflow 周围搜索,但无法解决我的问题,我的 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'

最佳答案

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

关于ios - AppDelegate 中的 PushingViewController 无法识别的选择器实例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37855317/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com