gpt4 book ai didi

iphone - Segue 不适用于 iOS6

转载 作者:行者123 更新时间:2023-12-03 18:52:17 24 4
gpt4 key购买 nike

如果我的问题对你们中的一些人来说可能听起来很愚蠢,请原谅。我对 iOS 开发比较陌生,但我必须为 iOS6 移植一个应用程序。该应用程序在 iOS 5 和 XCode 4.3.2 上完美运行,但我在 iPhone 6.0 模拟器上使用 Xcode 4.5 时遇到了一个奇怪的错误。加载初始屏幕后,我可以点击任何我想要的按钮,但我收到错误:

 `Terminating app due to uncaught exception 'NSGenericException', reason: 'Could not find a navigation controller for segue 'register'. Push segues can only be used when the source controller is managed by an instance of UINavigationController.`

StartScreenViewController的prepareForSegue方法如下所示

if ([[segue identifier] isEqualToString:@"register"] || [[segue identifier] isEqualToString:@"forgotPassword"]) {
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:[segue destinationViewController]];
appDelegate.window.rootViewController = navController;
}

设置断点表明该方法仍然被正确调用,但是在prepareForSegue完成后,应用程序崩溃并出现上述错误。有人能指出我正确的方向吗?

非常感谢马丁

最佳答案

你可以说“应用程序运行得很好”,但事实是你引用的代码总是非常错误,所以看起来这个错误现在正在被暴露。您永远不应该在应用程序中间更改窗口的 Root View Controller ;您应该在启动时设置一次,然后再不要设置。而且,正如 Joshua 正确所说的那样,准备 Segue 并不是你去搞乱 View Controller 结构的时候,因为 Segue 本身就会搞乱 View Controller 结构。

你手上有一个篮子。在采取下一步之前,最好先停下来了解 iOS 并查看 Controller (和 Storyboard ),因为您最终可能会为了得到正确的结果而破坏该应用程序的整个架构。这里有一些帮助:

http://www.apeth.com/iOSBook/ch19.html

关于iphone - Segue 不适用于 iOS6,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12654172/

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