Iphone UIDatePicker计划程序错误

Iphone UIDatePicker计划程序错误,iphone,ipad,xcode4.5,uidatepicker,appdelegate,Iphone,Ipad,Xcode4.5,Uidatepicker,Appdelegate,我遵循了这个教程 –本地通知/ 我可以运行该应用程序,但是为了运行该应用程序,我已经删除了appdelegate.m中的以下代码 您可以在上图中看到错误 为什么我会收到错误,如何修复错误 这是我的密码 h 您必须首先创建viewController的实例: ViewController *viewController = [[ViewController alloc] init]; // set the frame, do other stuff.. [_window addSubview:v

我遵循了这个教程 –本地通知/ 我可以运行该应用程序,但是为了运行该应用程序,我已经删除了appdelegate.m中的以下代码

您可以在上图中看到错误

为什么我会收到错误,如何修复错误

这是我的密码

h


您必须首先创建
viewController
的实例:

ViewController *viewController = [[ViewController alloc] init];
// set the frame, do other stuff..
[_window addSubview:viewController.view];

请先检查您的AppDelegate代码

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];

   /******
       YOUR CODE HERE

   ******/

    self.window.rootViewController = self.viewController;
    [self.window makeKeyAndVisible];


    return YES;
}

好的,在玩了一些游戏之后。我能够让应用程序运行,而无需更改应用程序代理

不知道他为什么在教程中说要这样做


谢谢你的帮助。

是的,对不起,意外地撞上了return。self.viewController=[[viewController alloc]initWithNibName:@“viewController”bundle:nil];必须将[[viewcontroller alloc]更改为[[viewcontroller alloc]。然后,我收到一个错误,说明:在类型为“AppDelegate*”的对象上找不到属性“viewController”;我在self.window.rootViewController=self.viewController行中也收到了相同的错误;我没有将BOOL添加到应用程序委派。
ViewController *viewController = [[ViewController alloc] init];
// set the frame, do other stuff..
[_window addSubview:viewController.view];
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];

   /******
       YOUR CODE HERE

   ******/

    self.window.rootViewController = self.viewController;
    [self.window makeKeyAndVisible];


    return YES;
}