2011. 1. 28.

objective-c UIView 동적로드

- (UIView*) loadViewWithNibName:(NSString*)nibName {
NSArray *nibViews = [[NSBundle mainBundle]
loadNibNamed:nibName
owner:nil
options:nil];
//[nibViews autorelease];

UIView* uiView = [nibViews objectAtIndex:0];
[ uiView autorelease];

return uiView;
}

- (void)applicationDidFinishLaunching:(UIApplication *)application {
// Override point for customization after app launch
ChangeViewTest2ViewController* myViewController = (ChangeViewTest2ViewController *)viewController;

viewController.view = [ self loadViewWithNibName:@"MainView"];
myViewController.subView1 = (SubView1*)[ self loadViewWithNibName:@"SubView1"];
myViewController.subView2 = (SubView2*)[ self loadViewWithNibName:@"SubView2"];
[window addSubview:viewController.view];
[window makeKeyAndVisible];
}

댓글 없음: