我正在使用XCode 4开发一个可以在iPhone 3.1.3上运行的应用程序.在iOS4模拟器上工作正常,但在我的设备上,我收到一个错误.
这是我收到错误的AppDelegate代码.
@implementation VoConstructorAppDelegate
@synthesize window=_window;
@synthesize viewController=_viewController;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
Run Code Online (Sandbox Code Playgroud)
我收到以下错误self.window.rootViewController = self.viewController;:
2011-07-07 15:10:20.997 VoConstructor[159:207] *** -[UIWindow setRootViewController:]: unrecognized selector sent to instance 0x11a9e0
2011-07-07 15:10:21.053 VoConstructor[159:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[UIWindow setRootViewController:]: unrecognized selector sent to instance 0x11a9e0'
Run Code Online (Sandbox Code Playgroud)
有什么建议?
由于rootViewController属性仅在iOS4.0中出现在UIWindow中,因此无法将其用于旧版平台.对于iOS 3.x,您必须手动将控制器的视图添加到UIWindow,您的代码将类似于:
if ([self.window respondsToSelector:@selector(setRootViewController:)])
self.window.rootViewController = self.viewController;
else
[self.window addSubview:self.viewController.view];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
532 次 |
| 最近记录: |