【发布时间】:2014-08-13 09:38:49
【问题描述】:
我有一个关于过渡的问题。
当我们想要转换到下一个UIViewController时,我们使用此代码:
UIViewController* secondViewController = [[UIViewController alloc] initWithNibName:@"SecondViewControllerName" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:secondViewController animated:YES];
或
当我们要使用此代码添加NavigationController 时:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
ViewController *viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:viewController];
self.window.rootViewController = navController;
[self.window makeKeyAndVisible];
return YES;
}
或
当我们想使用此代码将UIViewController 添加到另一个UIViewController 时:
UIViewController* secondViewController = [[UIViewController alloc] initWithNibName:@"SecondViewControllerName" bundle:[NSBundle mainBundle]];
[self.view addSubview:secondViewController.view];
现在我想知道如果我的项目中不使用xib 文件该怎么办???
【问题讨论】:
-
那你在用故事板吗??
-
@vishnuvarthan 没有我的朋友没有故事板没有 xib 文件
-
所以你想用一个空的应用程序模板以编程方式做所有事情
-
@vishnuvarthan 是的,我的朋友请指导我
标签: ios objective-c uiviewcontroller xib