gpt4 book ai didi

iphone - 应用程序中无法识别的选择器 didFinishLaunchingWithOptions 与 topViewController 分配

转载 作者:行者123 更新时间:2023-11-28 20:36:11 27 4
gpt4 key购买 nike

这是什么原因造成的?我在 Xcode 4.3 上运行 iOS 5.1 并使用 Storyboard。

'NSInvalidArgumentException', reason: '-[WFTopTableViewController topViewController]: unrecognized selector sent to instance 0x6d56f80'


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Initial view controller is a Table View Controller, so we look up the window's rootViewController.
UINavigationController *navigationController = (UINavigationController *)self.window.rootViewController;
// Set up the controller.
WFTopTableViewController *controller = (WFTopTableViewController *)navigationController.topViewController;
// Pass the controller the managed object context for the first time.
controller.managedObjectContext = self.managedObjectContext;
return YES;
}

谢谢!阿曼达

最佳答案

试试这个:

(BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions {
WFTopTableViewController *controller = (WFTopTableViewController*)self.window.rootViewController;
controller.managedObjectContext = self.managedObjectContext;
return YES;
}

您的窗口的 rootViewController 已经是 WFTopTableViewController,而不是 UINavigationController。如果您想要相反的方式,请确保在 Interface Builder 中为 UINavigationController 选择“是初始 View Controller ”选项。

关于iphone - 应用程序中无法识别的选择器 didFinishLaunchingWithOptions 与 topViewController 分配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10442283/

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