0
보통 뷰 컨트롤러는 다음과 같이 응용 프로그램 위임 초기화합니다 :뷰 컨트롤러시 초기화
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch
TestViewController *VC = [[TestViewController alloc] **init**];
self.window.rootViewController = VC;
return YES;
}
그러나 VC
이 - (instancetype)initWithNibName:
처럼 초기화 방법을 구현합니다.
어떻게합니까 init
initWithNibName:
으로 전화 하시겠습니까? 호출 시퀀스 란 무엇입니까? 기본 초기화 방법은 당신을 위해 initWithNibName:nibNameOrNil
의 슈퍼 구현을 호출하기 때문에, initWithNibName
을 구현
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
필요하지 않습니다 :
'init'은'initWithNibName : '을 호출하지 않습니다. –
그래서 모든 viewController는 "init"메소드를 구현해야하고 "init"메소드는 "initWithNibName"을 호출해야합니까? – user1743514
에 따라 다릅니다. nibs를 사용하지 않는다면'initWithNibName'을 호출 할 필요가 없습니다. –