<分区>
<分区>
Possible Duplicate:
How to change the default View Controller that is loaded when app launches?
因此,如果我制作了一个应用程序,并且默认情况下首先打开某个 View ,并且决定要更改首先打开哪个 View ,我该怎么做?
最佳答案
这是由 AppDelegate.m 文件(或应用程序委托(delegate)文件的标题)中名为 didFinishLaunchingWithOptions 的方法控制的。例如,在我创建的标签栏应用程序中,它看起来像这样:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
// Add the tab bar controller's current view as a subview of the window
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
return YES;
}
您所要做的就是更改 self.window.rootViewController 的值。例如,假设您希望 MapViewController 成为打开的第一个页面。你可以这样做:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
// Add the tab bar controller's current view as a subview of the window
MapViewController *mvc = [[MapViewController alloc]initWithNibName:@"MapViewController" bundle:nil]; //Allocate the View Controller
self.window.rootViewController = mvc; //Set the view controller
[self.window makeKeyAndVisible];
[mvc release]; //Release the memory
return YES;
}
关于ios - 更改首先打开的 View (Xcode),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7512107/