我遇到问题。我开发了一个应用程序,这个应用程序在iOS 4.2上成功运行。现在我想在iOS 3.2上运行它,但应用程序在加载之前会崩溃。由于此行的代码:iphone:在iOS 3.2上运行iOS 4.2的应用程序
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(myMethod) name:UIApplicationWillEnterForegroundNotification object:nil];
我明白UIApplicationWillEnterForegroundNotification不支持iOS 3.2。但是当我使用时:
#ifdef __IPHONE_4_0
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reloadDataAfterEnterForeground) name:UIApplicationWillEnterForegroundNotification object:nil];
#endif
该应用程序仍在该行代码中运行,并再次导致崩溃。我不知道我应该怎么做让3.2不运行该代码行。
非常感谢你
您的#ifdef被评估在编译时不是运行时。如果你将你的应用程序与ios 4.2 sdk链接,则条件满足。 – Kai 2011-03-04 09:26:30