gpt4 book ai didi

ios - UINavigationController 推送因无法识别的选择器 barStyle 而崩溃

转载 作者:行者123 更新时间:2023-11-29 12:47:48 33 4
gpt4 key购买 nike

很确定这是一个内存相关的问题,但它总是发生在同一个地方,当我将一个新 Controller 推到导航 Controller 堆栈上时

CurrentActivityViewController *controller = [[CurrentActivityViewController alloc] init];
controller.delegate = self;
[controller setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
[self.navigationController presentViewController:controller animated:NO completion:nil];

崩溃总是有一个随机的接收对象,但总是在相同的堆栈调用之前,这是另一个有趣的花絮,这似乎只发生在运行 7.0 的 4 和 4s 设备上,似乎无法在运行 7.0 的模拟器上重现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 选择器一起崩溃,在我的应用程序委托(delegate)中,我使用 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 Controller 的崩溃,但如果不重现这个,我就无法提交错误报告,关于在哪里寻找问题有什么想法吗?

最佳答案

如果这是模态视图,则需要从当前 View Controller 本身呈现它,而不是从它的导航 Controller

这一行...

[self.navigationController presentViewController:controller animated:NO completion:nil];

应该是……

[self presentViewController:controller animated:NO completion:nil];

看看 Apple Docs了解更多信息

关于ios - UINavigationController 推送因无法识别的选择器 barStyle 而崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23199276/

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