- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
Xcode 7.0.1
更新:
我最近尝试的是分解 UINavigationController 的创建:
self.viewController = [[ProjectsViewController alloc] initWithNibName:@"ProjectsViewController_iPhone" bundle:nil];
self.navigationController = [[UINavigationController alloc] init];
[self.navigationController setViewControllers:@[self.viewController]];
self.window.rootViewController = self.navigationController;
[self.window makeKeyAndVisible];
这样做崩溃现在就开始了
[self.window makeKeyAndVisible];
但痕迹完全一样。
我也通过更改 vanilla ViewController 尝试过此操作
[self.navigationController setViewControllers:@[[[UIViewController alloc] init]]];
同样的结果...
原帖:
我遇到了一个我很难理解的崩溃 - 这是 lldb 跟踪:注意 2147483648
的索引*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM removeObjectAtIndex:]: index 2147483648 beyond bounds [0 .. 2]'
*** First throw call stack:
(
0 CoreFoundation 0x035eaa94 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x03084e02 objc_exception_throw + 50
2 CoreFoundation 0x034f92ed -[__NSArrayM removeObjectAtIndex:] + 445
3 UIKit 0x018c20b2 -[UIView(Hierarchy) bringSubviewToFront:] + 260
4 UIKit 0x0193daeb -[UINavigationBar layoutSubviews] + 3692
5 UIKit 0x018d716b -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 813
6 libobjc.A.dylib 0x03099059 -[NSObject performSelector:withObject:] + 70
7 QuartzCore 0x0096e60c -[CALayer layoutSublayers] + 144
8 QuartzCore 0x0096228e _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 388
9 QuartzCore 0x00970b2c -[CALayer(CALayerPrivate) layoutBelowIfNeeded] + 44
10 UIKit 0x018c4dca -[UIView(Hierarchy) layoutBelowIfNeeded] + 1244
11 UIKit 0x01a117cf __74-[UINavigationController _positionNavigationBarHidden:edge:initialOffset:]_block_invoke + 36
12 UIKit 0x018caca6 +[UIView(Animation) performWithoutAnimation:] + 82
13 UIKit 0x01a1178d -[UINavigationController _positionNavigationBarHidden:edge:initialOffset:] + 922
14 UIKit 0x01a1194c -[UINavigationController _positionNavigationBarHidden:edge:] + 326
15 UIKit 0x01a12d5f -[UINavigationController _positionNavigationBarHidden:] + 49
16 UIKit 0x01a1104a -[UINavigationController setNavigationBar:] + 1224
17 UIKit 0x01a10a38 -[UINavigationController _navigationBarHiddenByDefault:] + 156
18 UIKit 0x01a10997 -[UINavigationController navigationBar] + 41
19 UIKit 0x01a17805 -[UINavigationController loadView] + 230
20 UIKit 0x019d3338 -[UIViewController loadViewIfRequired] + 138
21 UIKit 0x019d3cf1 -[UIViewController view] + 35
22 UIKit 0x01a22226 -[UINavigationController pushViewController:transition:forceImmediate:] + 615
23 UIKit 0x01a21e27 __54-[UINavigationController pushViewController:animated:]_block_invoke + 351
24 UIKit 0x01a21c83 -[UINavigationController pushViewController:animated:] + 786
25 UIKit 0x01a07be2 -[UINavigationController initWithRootViewController:] + 140
26 DELETIA 0x0012954e -[AppDelegate application:didFinishLaunchingWithOptions:] + 1214
这是一个成熟的应用程序,已经构建和运行了一段时间,但在当前的 XCode 中会发生上述情况。
如您所见,调用了 UINavigationController:initWithRootViewController - 这是代码:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// deletia - non UIKit code
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.tintColor = [UIColor darkGrayColor];
self.viewController = [[ProjectsViewController alloc] initWithNibName:@"ProjectsViewController_iPhone" bundle:nil];
self.navigationController = [[UINavigationController alloc] initWithRootViewController:self.viewController];
// deletia - but the app crashes on the above line
}
在看了一些类似的问题后,我尝试了一些事情,并且 在这里回答。
我听说如果基于 View Controller 的状态栏会发生这种情况外观在 Info.plist 中设置为 YES - 所以我将其设置为 NO/是的
我听说一些 UIGestureRecognizers 会导致问题 - 所以我检查了 XIB 并确保没有任何影响此 View Controller 。
我听说如果 Root View Controller 没有完全初始化这可能会有问题 - 所以我推迟了对UINavigationController 1 秒
我不信任 ProjectsViewController - 所以我用它代替了 Vanilla UIViewController 因此:
self.navigationController = [[UINavigationController alloc] initWithRootViewController:[[UIViewController alloc] init]];
非常感谢任何见解;无论是在可能导致问题的原因中,还是在调试技术中,都可能对问题有所启发。
最佳答案
我认为您关注的是错误的代码段。正如您所提到的,它在 [self.window makeKeyAndVisible]
行崩溃,但是,可能导致崩溃的原因是该行导致 ProjectsViewController
和 UINavigationController
对象加载并呈现给用户。查看您发布的崩溃日志,这是您应该调查的部分:
2 CoreFoundation 0x034f92ed -[__NSArrayM removeObjectAtIndex:] + 445
3 UIKit 0x018c20b2 -[UIView(Hierarchy) bringSubviewToFront:] + 260
4 UIKit 0x0193daeb -[UINavigationBar layoutSubviews] + 3692
你可以在这里看到 iOS 尝试对 UINavigationBar 的 subview 进行布局,然后在可能是 NSNotFound
的索引处删除一个对象(这将导致 NSIntegerMax
,这匹配您在崩溃日志中提到的索引)。
为了进一步研究崩溃,我建议执行以下步骤:
ProjectsViewController
实例替换为没有自定义 .xib 文件的 UIViewController
实例。 (我在你原来的帖子中读到你已经尝试过这个,但我仍然建议将此作为第一步,以消除其他问题,如果有多个问题,在完全解决崩溃的过程中)。重要的是要确保此时您没有使用 .xib 文件,因为它可能是导致崩溃的原因(如果有任何错误链接的导出或类似问题)。removeObjectAtIndex
或任何其他可能在初始 View Controller 的加载和显示过程中调用的 NSMutableArray
相关调用的位置。在这些地方加个断点,看看在初始加载过程中是否到达了。如果是这样,请尝试在那里添加测试以确保您尝试从中删除对象的索引大于或等于零并且小于数组的大小。这样,如果您尝试访问的索引是 NSNotFound
,它至少不会导致应用程序崩溃(无论当前崩溃如何,这是一个很好的做法)。如果这最终解决了问题,您可以进一步调查问题并尝试理解为什么 NSNotFound
实际上作为索引接收并从逻辑上解决问题。我希望这些步骤之一可以帮助识别和解决您的问题。祝你好运!
关于ios - 调试 UIKit 崩溃 [UINavigationController initWithRootViewController],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32892105/
我有几个由导航 Controller 控制的 View Controller 。 例如,viewController A 和 viewController B 都可以将 viewController
目前我在单独的 Storyboard中有一个导航 Controller ,它使用退出按钮。这个退出按钮应该返回到 rootViewController(那是在 mainstoryboard 中)这是一
我目前正在将我的应用程序迁移到 iOS 7 上,并且在新的导航 Controller /栏管理上已经卡了好几个小时了。 之前,当我们有导航 Controller 时,我们有这样的代码片段: UINav
我环顾四周,终究找不到用滑动手势替换 backbarbuttonitem 的方法。我想向左滑动并让应用恢复到之前的 View Controller 。澄清一下,我正在使用 UINavigationCo
我环顾四周,终究找不到用滑动手势替换 backbarbuttonitem 的方法。我想向左滑动并让应用恢复到之前的 View Controller 。澄清一下,我正在使用 UINavigationCo
我使用 320*44 图像自定义 NavigationBar backgroundImage。因此状态栏为黑色。这就是我想要的。但是,当我呈现此 navigationController 时,如您所知
我正面临以下代码的崩溃。场景是 这是我的应用委托(delegate)方法,我在其中使用 UINavigationController 加载 RTC_HomeVC。 - (BOOL)applicatio
目前我有一个使用 uinavigationcontroller 但仅在 Root View 中隐藏导航栏的应用程序,我想在某些应用程序中将此应用程序用作外部库并将整个应用程序作为一个菜单项推送。 但是
我有两个 View Controller ,ViewControllerA 和 ViewControllerB,嵌入在 UINavigationController 中。 ViewController
iOS 7 采用了一种新手势,在屏幕上从左到右滑 Action 为 UINavigationController 中返回按钮的快捷方式。 我的应用似乎没有免费采用这种行为。我需要做什么才能使这个手势可
我已经在这上面花了几个小时,但无法让它工作。希望有人能帮助我。 我有一个 UIPageViewController,当我在应用程序启动时将它添加到我的默认 View 时,它可以完美地工作。这就是我所做
我想为我的 UIToolbar 使用我自己的背景。 要使用 UINavigationBar 做到这一点,我刚刚使用了这个类别并覆盖了 drawRect 方法: @implementation
我正在展示一个 UINavigationController模态地,从 iOS 应用程序扩展中: UINavigationController *nav = [[UINavigationControl
我读到在 iOS 应用程序中有这样的结构是不好的。但是,如果应用程序有很多 UINavigationController 和 UITabBarController 怎么办?但是一个UINavigati
我们在 UISplitViewController 应用程序中有我们需要的特定行为。我们有以下 3 个 View 的层次结构 FormOneViewController - 在 MasterView
我试图将一个简单的 UIToolbar 放在模态呈现的 UINavigationController 的底部。在这个示例中,它应该包含两个按钮“取消”和“某事”。 ... UINavigationCo
我有一个 UITabBarController,其中包含一些选项卡。其中一个选项卡具有 UINavigationController 和 UITableViewController 作为 Root V
我的应用程序的整个导航系统都是围绕导航 Controller 构建的。我所有的风险投资公司都被插入和推出。我有一个从左侧出来的菜单系统“抽屉”,它是我的自定义导航 Controller 的一部分。在菜
我有一个 UINavagationController (NC),它显示“Items”数组的多个 UIViewController (VC) View ,并且我有一个 UINavigationCont
在我的 UISplitViewController ,主 View 是UINavigationController包含 UITableViewController .有时,当用户选择表中的项目时,我不
我是一名优秀的程序员,十分优秀!