iPhone - 在iOS 3.x上启动应用程序时崩溃(_UIApplicationDidEnterBackgroundNotification)
我在我的应用程序中支持iOS 3.0及以上版本的Three20。iPhone - 在iOS 3.x上启动应用程序时崩溃(_UIApplicationDidEnterBackgroundNotification)
当我用iOS 3.0,iOS 3.1运行应用程序时,应用程序在启动时立即崩溃。
下面是我的崩溃报告:
Date/Time: 2012-06-26 10:38:36.761 -0600
OS Version: iPhone OS 3.1.3 (7E18)
Report Version: 104
Exception Type: EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x00000001, 0xe7ffdefe
Crashed Thread: 0
Dyld Error Message:
Symbol not found: _UIApplicationDidEnterBackgroundNotification
Referenced from: /var/mobile/Applications/8E9E6F79-80BB-4CCD-A510-CCBF7BB78BE8/MyApp.app/MyApp
Expected in: /System/Library/Frameworks/UIKit.framework/UIKit
Dyld Version: 149
你知道是怎么回事,
我缺少在构建设置的东西吗?
更新1:
所以我做了搜索UIApplicationDidEnterBackgroundNotification时在我的项目
,并有在TTBaseNavigator.m文件中发现3分的结果。
一个在这一领域
#ifdef __IPHONE_4_0
UIKIT_EXTERN NSString *const UIApplicationDidEnterBackgroundNotification
__attribute__((weak_import));
UIKIT_EXTERN NSString *const UIApplicationWillEnterForegroundNotification
__attribute__((weak_import));
#endif
两个在这种方法
- (id)init {
self = [super init];
if (self) {
_URLMap = [[TTURLMap alloc] init];
_persistenceMode = TTNavigatorPersistenceModeNone;
NSNotificationCenter* center = [NSNotificationCenter defaultCenter];
[center addObserver:self
selector:@selector(applicationWillLeaveForeground:)
name:UIApplicationWillTerminateNotification
object:nil];
#ifdef __IPHONE_4_0
if (nil != &UIApplicationDidEnterBackgroundNotification) {
[center addObserver:self
selector:@selector(applicationWillLeaveForeground:)
name:UIApplicationDidEnterBackgroundNotification
object:nil];
}
#endif
}
return self;
}
你知道如何调整这些代码,使应用程序将在iOS 3.0和iOS 3.1的运行。
更新2:
目前我不使用TTBaseNavigator所以我评论两个的#ifdef __IPHONE_4_0块。
这解决了我的问题,但我想知道是否有其他解决方案通过不评论Three20代码来完成此工作。
非常感谢。
我评论了两个#ifdef __IPHONE_4_0块。 (请参阅更新1)
这解决了我的问题。
在UIApplicationDidEnterBackgroundNotification
事件的文档中,它提到“可用于iOS 4.0及更高版本”。
感谢菲利普斯提醒我,我完全忘了这一点。 –
在Xcode中设置了应用程序的部署目标是什么?我会认为将其设置为3.x会导致该代码被编译器忽略。 –
开发目标是iOS 3.0 –