10

프로그래밍 방식으로 목록보기 컨트롤러를 구현하고 있습니다. 내가 프로젝트를 실행하려고하면 , 나는 오류가 있어요 : 나는이 코드를 실행하면응용 프로그램 대리인은 기본 스토리 보드 파일을 사용하려는 경우 window 속성을 구현해야합니다.

2012-11-07 22:46:34.719 myTableViewControl[12021:c07] The app delegate must implement the   window property if it wants to use a main storyboard file. 
2012-11-07 22:46:34.722 myTableViewControl[12021:c07] -[AppDelegate setWindow:]:  unrecognized selector sent to instance 0x7674e70 
2012-11-07 22:46:34.723 myTableViewControl[12021:c07] *** Terminating app due to uncaught  exception 'NSInvalidArgumentException', reason: '-[AppDelegate setWindow:]: unrecognized  selector sent to instance 0x7674e70' 
*** First throw call stack: 
(0x1c8e012 0x10cbe7e 0x1d194bd 0x10df7ea 0x1c7dcf9 0x1c7d94e 0x1d60 0x107b7 0x10da7  0x11fab 0x23315 0x2424b 0x15cf8 0x1be9df9 0x1be9ad0 0x1c03bf5 0x1c03962 0x1c34bb6 0x1c33f44  0x1c33e1b 0x117da 0x1365c 0x1bd2 0x1b05) 
libc++abi.dylib: terminate called throwing an exception 
(lldb) 

가,가 main.m에 걸어 및

"thread1: signal SIGABRT"

@autoreleasepool {return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 

내 코드가 같은 것을 보여준다 다음 AppDelegate.h

// 
// AppDelegate.h 
// myTableViewControl 
// 
// Created by Max on 12-11-5. 
// Copyright (c) 2012年 Max. All rights reserved. 
// 

#import <UIKit/UIKit.h> 

@interface AppDelegate : UIResponder <UIApplicationDelegate> 

@property (strong, nonatomic) UINavigationController *navigationController; 


@end 

에게 AppDelegate.m

// 
// AppDelegate.m 
// myTableViewControl 
// 
// Created by Max on 12-11-5. 
// Copyright (c) 2012年 Max. All rights reserved. 
// 

    #import "AppDelegate.h" 
    #import "firstViewController.h" 


@implementation AppDelegate 
@synthesize navigationController; 


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions: (NSDictionary *)launchOptions 
{ 
    // create the base window 
    UIWindow *window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 
    window.backgroundColor = [UIColor greenColor]; 
    self.window = window; 

    [window release]; 

    // this is the home page from the user's perspective 

    FirstViewController *fvc = [[FirstViewController alloc] init]; 

    UINavigationController *nc = [[UINavigationController alloc]initWithRootViewController:fvc]; 
    self.navigationController = nc; 

    [fvc release]; 
    [nc release]; 

    // show them 
    [self.window addSubview: nc.view]; 
    [self.window makeKeyAndVisible]; 

    return YES; 
} 

@end 

FirstViewController는 목록보기 컨트롤러입니다.

답변

15

로컬 변수로 창을 만든 다음 self.window을 사용하여 창을 속성 인 것처럼 액세스하려고합니다. 재산으로 만들어라.

+4

필립은 정확합니다. 이 줄은 헤더 파일에서 누락되었습니다. '@property (강한, 비 원자) UIWindow * 창; – Cashew

+0

thnx so .... much. ios에있는 새로운 사람, 많은 도움을주었습니다. – max

+1

또한'@ property'가 이미 있는데 런타임 오류가 발생하면'@ synthesize'를했는지 확인하십시오. 어떻게 든 기적적으로 ** Xcode 4.5 및 iPhone 5 용 **없이 작동합니다.이 오류를 미리 발견 했으므로 다른 조합을 시도하지 않았습니다. –