- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
UIColor *navBarColor =
[UIColor colorWithPatternImage:[UIImage imageNamed:@"SandPattern.jpg"]];
if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1 {
[[UINavigationBar appearance] setTintColor:navBarColor];
}
else {
[[UINavigationBar appearance] setBarTintColor:navBarColor];
}
// various functions....
return YES;
}
应用程序崩溃并抛出以下错误。
*** -[UICGColor encodeWithCoder:], /SourceCache/UIKit/UIKit-3318/UIColor.m:1448
*** -[UICGColor encodeWithCoder:], /SourceCache/UIKit/UIKit-3318/UIColor.m:1448
libc++abi.dylib
:terminate_handler意外地抛出异常
答案 0 :(得分:0)
我移动代码将导航栏更新为一个函数,并在其他人在AppDelegate.m中运行后调用它,它运行正常。仍然在寻找崩溃背后的确切逻辑。
-(void)updateUI{
UIColor *navBarColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"SandPattern.jpg"]];
// [UIColor colorWithRed:129/255.0 green:200/255.0 blue:244/255.0 alpha:1.0];
if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1){
[[UINavigationBar appearance] setTintColor:navBarColor ];
}
else {
[[UINavigationBar appearance] setBarTintColor: navBarColor];
}
}
这样的最终代码
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
// various functions....
[self updateUI];
return YES;
}