Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/facebook/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 更改首先打开的视图(Xcode)_Ios_Xcode_View - Fatal编程技术网

Ios 更改首先打开的视图(Xcode)

Ios 更改首先打开的视图(Xcode),ios,xcode,view,Ios,Xcode,View,可能重复: 因此,如果我制作了一个应用程序,并且某个视图在默认情况下首先打开,并且决定要更改首先打开的视图,我将如何执行此操作?该操作由AppDelegate.m文件(或应用程序委派文件的标题)中名为didFinishLaunchingWithOptions的方法控制。例如,在我创建的选项卡栏应用程序中,它如下所示: - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDiction

可能重复:


因此,如果我制作了一个应用程序,并且某个视图在默认情况下首先打开,并且决定要更改首先打开的视图,我将如何执行此操作?

该操作由AppDelegate.m文件(或应用程序委派文件的标题)中名为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;
}
- (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;
}
您所要做的就是更改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

    self.window.rootViewController = self.tabBarController;
    [self.window makeKeyAndVisible];
    return YES;
}
- (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;
}