iOS 7只有应用程序在启动时崩溃 [英] iOS 7 Only App Crashes at Startup

查看:517
本文介绍了iOS 7只有应用程序在启动时崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近将我的xcode项目更改为iOS 7而不是支持iOS 5.
在应用程序启动后进行此更改后,我在控制台中收到此消息。

I recently changed my xcode project to be iOS 7 only instead of supporting iOS 5. After making this change as soon as the app starts I get this message in the console.

-[UICachedDeviceWhiteColor shadowColor]: unrecognized selector sent to instance 0x156f22f0

我不知道是什么原因造成的。但是使用调试器,似乎我的应用程序委托崩溃了第一行代码。

I'm not sure what is causing this. But using the debugger it seems like my app delegate is crashing at the first line of code.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

self.window.rootViewController = self.tabBarController; //this line is where it crashes

[self.window makeKeyAndVisible];

任何帮助将不胜感激。

推荐答案

你可能做了我做的,并且过度削减并替换了UITextAttributeTextShadowColor和UITextAttributeTextShadowOffset的编译器警告。所以你有这样的代码:

You probably did what I did, and overzealously cut and replaced the compiler warnings for UITextAttributeTextShadowColor and UITextAttributeTextShadowOffset. So you had code that looked like this:

NSDictionary *titleAttributes = @{UITextAttributeTextColor: [UIColor whiteColor],
                                  UITextAttributeTextShadowColor: [UIColor blackColor],
                                  UITextAttributeTextShadowOffset: [NSValue valueWithUIOffset:UIOffsetMake(1, 0)],
                                  UITextAttributeFont: [UIFont titleBolder]};
[[UINavigationBar appearance] setTitleTextAttributes:titleAttributes];

并用NSShadowAttributeName替换它们,最终得到如下代码:

and replaced them both with NSShadowAttributeName, and ended up with some code like this:

NSDictionary *titleAttributes = @{NSForegroundColorAttributeName: [UIColor whiteColor],
                                  NSShadowAttributeName: [UIColor blackColor],
                                  NSShadowAttributeName: [NSValue valueWithUIOffset:UIOffsetMake(1, 0)],
                                  NSFontAttributeName: [UIFont titleBolder]};
[[UINavigationBar appearance] setTitleTextAttributes:titleAttributes];

你需要做的是有一个属性NSShadowAttributeName,并创建一个NSShadow的实例,颜色和阴影偏移。

What you need to do is have one attribute NSShadowAttributeName, and create an instance of NSShadow that contains the shadow color and shadow offset.

NSShadow *shadow = [[NSShadow alloc] init];
shadow.shadowColor = [UIColor blackColor];
shadow.shadowOffset = CGSizeMake(1, 0);
NSDictionary *titleAttributes = @{NSForegroundColorAttributeName: [UIColor whiteColor],
                                  NSShadowAttributeName: shadow,
                                  NSFontAttributeName: [UIFont titleBolder]};
[[UINavigationBar appearance] setTitleTextAttributes:titleAttributes];

这篇关于iOS 7只有应用程序在启动时崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆