非常肯定这是一个与内存相关的问题,但是当我将新控制器推入导航控制器堆栈时,它总是发生在同一个地方
CurrentActivityViewController *controller = [[CurrentActivityViewController alloc] init];
controller.delegate = self;
[controller setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
[self.navigationController presentViewController:controller animated:NO completion:nil];
崩溃总是有一个随机的接收对象,但总是在相同的堆栈调用之前,这似乎只发生在运行7.0的4和4s设备上的另一个有趣的消息,似乎无法在运行于的模拟器上重现3.5英寸的设备,再次回到内存问题,所以不会有太大的帮助。
Thread : Crashed: com.apple.main-thread
0 libobjc.A.dylib 0x39b42b26 objc_msgSend + 5
1 UIKit 0x32039677 -[_UINavigationPaletteBackground _syncWithBarStyles] + 42
2 UIKit 0x3203924b -[_UINavigationPaletteBackground updateBackgroundView] + 94
3 UIKit 0x324e4bd3 +[_UIBackdropView setAllBackdropViewsToGraphicsQuality:] + 458
4 UIKit 0x31f297b5 __85-[UIView(Hierarchy) _makeSubtreePerformSelector:withObject:withObject:copySublayers:]_block_invoke + 76
5 UIKit 0x31f296e5 -[UIView(Hierarchy) _makeSubtreePerformSelector:withObject:withObject:copySublayers:] + 376
6 UIKit 0x31f297d5 __85-[UIView(Hierarchy) _makeSubtreePerformSelector:withObject:withObject:copySublayers:]_block_invoke + 108
7 UIKit 0x31f296e5 -[UIView(Hierarchy) _makeSubtreePerformSelector:withObject:withObject:copySublayers:] + 376
8 UIKit 0x31f365c3 -[UIView(Internal) _addSubview:positioned:relativeTo:] + 418
9 UIKit 0x31f36417 -[UIView(Hierarchy) addSubview:]
10 UIKit 0x32017d8f -[UITransitionView transition:fromView:toView:removeFromView:] + 978
11 UIKit 0x320173b3 __101-[UIWindowController transition:fromViewController:toViewController:target:didEndSelector:animation:]_block_invoke_2
12 UIKit 0x320151b1 -[UIWindowController transition:fromViewController:toViewController:target:didEndSelector:animation:]
13 UIKit 0x32012e25 -[UIViewController presentViewController:withTransition:completion:] + 4668
14 roadid 0x001195b7 __67-[NewActivitySetupViewController activityViewControllerStartTimer:]_block_invoke (NewActivitySetupViewController.m:1372)
事情是它与最随机的对象崩溃,但总是使用 barStyle 选择器,在我的app委托中我使用UIAppearance代理在UINavigationController上设置一些样式的东西,这是我唯一的一个点甚至搞乱UINavigationController样式但从未特别 barStyle
if([self iOSIdentifier] == iOSVersion7)
{
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"titlebar_iOS7.png"] forBarMetrics:UIBarMetricsDefault];
} else {
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"title_bar.png"] forBarMetrics:UIBarMetricsDefault];
}
[[UINavigationBar appearance] setTitleTextAttributes:@{UITextAttributeTextColor: [UIColor whiteColor],
UITextAttributeTextShadowColor: [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.8f],
UITextAttributeTextShadowOffset: [NSValue valueWithUIOffset:UIOffsetMake(0, -1)]}];
[[UINavigationBar appearanceWhenContainedIn:[ABPeoplePickerNavigationController class],[ABNewPersonViewController class], nil] setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
最后这看起来像苹果内部的uinavigation控制器崩溃,但没有重现这个我不能提交错误报告,任何关于在哪里寻找问题的想法?
答案 0 :(得分:1)
如果这是模态视图,您需要从当前视图控制器本身而不是从其导航控制器中显示它
这一行...
[self.navigationController presentViewController:controller animated:NO completion:nil];
应该是......
[self presentViewController:controller animated:NO completion:nil];
查看Apple Docs以获取更多信息
答案 1 :(得分:0)
您无法按模式推送到navigationController。如果你需要推送到navigationController删除modalTransitionStyle并将推送方法更改为:
[self.navigationController pushViewController:controller animated:YES]