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

查看:35
本文介绍了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天全站免登陆