Iphone 如何为具有splitview控制器的应用程序提供登录屏幕?

Iphone 如何为具有splitview控制器的应用程序提供登录屏幕?,iphone,ios,objective-c,uisplitviewcontroller,Iphone,Ios,Objective C,Uisplitviewcontroller,当我将UISplitviewController指定为应用程序的根视图时,当时运行良好,但现在我想将登录屏幕添加到我的应用程序中。有人可以帮助我吗?提前谢谢。创建一个新的ViewController,然后将其指定为根视图ViewController 在此newViewController中,检查用户名和密码是否正确,然后加载splitsviewcontroller或显示拒绝访问消息。创建一个新的ViewController,然后将其分配为根ViewController 在此newViewCont

当我将UISplitviewController指定为应用程序的根视图时,当时运行良好,但现在我想将登录屏幕添加到我的应用程序中。有人可以帮助我吗?提前谢谢。

创建一个新的ViewController,然后将其指定为根视图
ViewController


在此
newViewController
中,检查用户名和密码是否正确,然后加载
splitsviewcontroller
或显示拒绝访问消息。

创建一个新的ViewController,然后将其分配为根
ViewController


在此
newViewController
中检查用户名和密码,如果正确,则加载您的
splitsviewcontroller
或显示拒绝访问消息。

您可以将您的LoginViewcontroller作为根视图控制器添加到代理ans中的LoginScreen loginbutton操作检查用户名或密码如果为真,则必须装箱代理的对象并将RootViewConterror设置为您的根视图控制器splitviewcontroller。就像我下面的代码:-

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{


    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

    self.viewController = [[LogInViewController alloc] initWithNibName:@"LogInViewController" bundle:nil];


     self.window.rootViewController = self.viewController;

       [self.window makeKeyAndVisible];
    return YES;

}
 UIInterfaceOrientation interfaceOrientation = HomeSpilitView.interfaceOrientation;
    NSString *subtypeDirection;
    if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft) {
        subtypeDirection = kCATransitionFromTop;
    }
    else if (interfaceOrientation == UIInterfaceOrientationLandscapeRight) {
        subtypeDirection = kCATransitionFromBottom;
    }
    else {
        subtypeDirection = kCATransitionFromRight;
    }
    [objAppdelegate.window setRootViewController:HomeSpilitView];
    CATransition *animation = [CATransition animation];
    [animation setDuration:0.5];
    [animation setType:kCATransitionPush];
    [animation setSubtype:subtypeDirection];
    [animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];

    [[objAppdelegate.window layer] addAnimation:animation forKey:@"SwitchToView1"];
以及您的登录按钮操作:

-(IBAction)loginclick:(id)sender
{
     objAppdelegate = (yourProjectnameDelegate *) [[UIApplication sharedApplication]delegate];
     NSMutableArray *array = [NSMutableArray array];

                HomeSpilitView = [[[UISplitViewController alloc] init]autorelease];

                HomeMster = [[HomeSpilitViewController alloc] initWithNibName:@"HomeSpilitViewController" bundle:nil];

                masterNavigationController = [[[UINavigationController alloc] initWithRootViewController:HomeMster] autorelease];
                HomeMster.title=@"Title home";
                masterNavigationController.navigationBar.tintColor =[UIColor colorWithRed:255/255.0 green:108/255.0 blue:61/255.0 alpha:0.1];
                [array addObject:masterNavigationController];


                HomeDetailsViewController *HomeDetailsViewControllers = [[HomeDetailsViewController alloc] initWithNibName:@"HomeDetailsViewController" bundle:nil];

                detailNavigationController = [[[UINavigationController alloc] initWithRootViewController:HomeDetailsViewControllers] autorelease];

                detailNavigationController.navigationBar.tintColor =[UIColor colorWithRed:255/255.0 green:108/255.0 blue:61/255.0 alpha:0.1];
                HomeDetailsViewControllers.title=@"details title";
                HomeMster.objHomeDetailsViewcontroller=HomeDetailsViewControllers;
                HomeSpilitView.delegate = HomeDetailsViewControllers;

              [array addObject:detailNavigationController];

              [HomeSpilitView setViewControllers:array];

              [objAppdelegate.window setRootViewController:HomeSpilitView];


}
更新 最后我用下面的代码完成了:-

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{


    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

    self.viewController = [[LogInViewController alloc] initWithNibName:@"LogInViewController" bundle:nil];


     self.window.rootViewController = self.viewController;

       [self.window makeKeyAndVisible];
    return YES;

}
 UIInterfaceOrientation interfaceOrientation = HomeSpilitView.interfaceOrientation;
    NSString *subtypeDirection;
    if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft) {
        subtypeDirection = kCATransitionFromTop;
    }
    else if (interfaceOrientation == UIInterfaceOrientationLandscapeRight) {
        subtypeDirection = kCATransitionFromBottom;
    }
    else {
        subtypeDirection = kCATransitionFromRight;
    }
    [objAppdelegate.window setRootViewController:HomeSpilitView];
    CATransition *animation = [CATransition animation];
    [animation setDuration:0.5];
    [animation setType:kCATransitionPush];
    [animation setSubtype:subtypeDirection];
    [animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];

    [[objAppdelegate.window layer] addAnimation:animation forKey:@"SwitchToView1"];

您可以将LoginViewcontroller作为根视图控制器添加到代理ans中的LoginScreen loginbutton操作检查用户名或密码。如果为真,则必须装箱代理的对象,并将rootviewconteroller设置为splitviewcontroller。就像我下面的代码:-

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{


    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

    self.viewController = [[LogInViewController alloc] initWithNibName:@"LogInViewController" bundle:nil];


     self.window.rootViewController = self.viewController;

       [self.window makeKeyAndVisible];
    return YES;

}
 UIInterfaceOrientation interfaceOrientation = HomeSpilitView.interfaceOrientation;
    NSString *subtypeDirection;
    if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft) {
        subtypeDirection = kCATransitionFromTop;
    }
    else if (interfaceOrientation == UIInterfaceOrientationLandscapeRight) {
        subtypeDirection = kCATransitionFromBottom;
    }
    else {
        subtypeDirection = kCATransitionFromRight;
    }
    [objAppdelegate.window setRootViewController:HomeSpilitView];
    CATransition *animation = [CATransition animation];
    [animation setDuration:0.5];
    [animation setType:kCATransitionPush];
    [animation setSubtype:subtypeDirection];
    [animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];

    [[objAppdelegate.window layer] addAnimation:animation forKey:@"SwitchToView1"];
以及您的登录按钮操作:

-(IBAction)loginclick:(id)sender
{
     objAppdelegate = (yourProjectnameDelegate *) [[UIApplication sharedApplication]delegate];
     NSMutableArray *array = [NSMutableArray array];

                HomeSpilitView = [[[UISplitViewController alloc] init]autorelease];

                HomeMster = [[HomeSpilitViewController alloc] initWithNibName:@"HomeSpilitViewController" bundle:nil];

                masterNavigationController = [[[UINavigationController alloc] initWithRootViewController:HomeMster] autorelease];
                HomeMster.title=@"Title home";
                masterNavigationController.navigationBar.tintColor =[UIColor colorWithRed:255/255.0 green:108/255.0 blue:61/255.0 alpha:0.1];
                [array addObject:masterNavigationController];


                HomeDetailsViewController *HomeDetailsViewControllers = [[HomeDetailsViewController alloc] initWithNibName:@"HomeDetailsViewController" bundle:nil];

                detailNavigationController = [[[UINavigationController alloc] initWithRootViewController:HomeDetailsViewControllers] autorelease];

                detailNavigationController.navigationBar.tintColor =[UIColor colorWithRed:255/255.0 green:108/255.0 blue:61/255.0 alpha:0.1];
                HomeDetailsViewControllers.title=@"details title";
                HomeMster.objHomeDetailsViewcontroller=HomeDetailsViewControllers;
                HomeSpilitView.delegate = HomeDetailsViewControllers;

              [array addObject:detailNavigationController];

              [HomeSpilitView setViewControllers:array];

              [objAppdelegate.window setRootViewController:HomeSpilitView];


}
更新 最后我用下面的代码完成了:-

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{


    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

    self.viewController = [[LogInViewController alloc] initWithNibName:@"LogInViewController" bundle:nil];


     self.window.rootViewController = self.viewController;

       [self.window makeKeyAndVisible];
    return YES;

}
 UIInterfaceOrientation interfaceOrientation = HomeSpilitView.interfaceOrientation;
    NSString *subtypeDirection;
    if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft) {
        subtypeDirection = kCATransitionFromTop;
    }
    else if (interfaceOrientation == UIInterfaceOrientationLandscapeRight) {
        subtypeDirection = kCATransitionFromBottom;
    }
    else {
        subtypeDirection = kCATransitionFromRight;
    }
    [objAppdelegate.window setRootViewController:HomeSpilitView];
    CATransition *animation = [CATransition animation];
    [animation setDuration:0.5];
    [animation setType:kCATransitionPush];
    [animation setSubtype:subtypeDirection];
    [animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];

    [[objAppdelegate.window layer] addAnimation:animation forKey:@"SwitchToView1"];
:

拆分视图控制器的视图应始终作为 应用程序窗口的根视图。你永远不应该分道扬镳 在导航或选项卡栏界面内部查看

使用模态视图控制器显示登录视图

或者试试:

拆分视图控制器的视图应始终作为 应用程序窗口的根视图。你永远不应该分道扬镳 在导航或选项卡栏界面内部查看

使用模态视图控制器显示登录视图

或者尝试:

  • 在导航控制器上创建注册、登录屏幕
  • 当您想跳转到SplitviewController时,只需将其设置为根视图控制器

    #define ApplicationDelegate  ((AppDelegate*)[[UIApplication sharedApplication] delegate])
    
    
    SplitHomeViewController *objSplitHomeVC = VCWithIdentifier(@"SplitHomeViewController_iPad");
    [ApplicationDelegate.window setRootViewController:(UIViewController*)objSplitHomeVC];
    
  • 在导航控制器上创建注册、登录屏幕
  • 当您想跳转到SplitviewController时,只需将其设置为根视图控制器

    #define ApplicationDelegate  ((AppDelegate*)[[UIApplication sharedApplication] delegate])
    
    
    SplitHomeViewController *objSplitHomeVC = VCWithIdentifier(@"SplitHomeViewController_iPad");
    [ApplicationDelegate.window setRootViewController:(UIViewController*)objSplitHomeVC];
    


  • 你正在使用Tabbarcontroller吗?你可以临时设置其他rootVC(在我的应用程序中这样做)不,我没有使用Tabbarcontroller。用我的答案演示登录视图控制器modallytest我刚刚测试了这个,并在这里发布希望它能帮助你使用Tabbarcontroller吗?你可以临时设置其他rootVC(在我的应用程序中这样做)不,我没有使用tabbarcontroller。用我的答案演示登录视图控制器modallytest,我只是测试一下,并在这里发布,希望它对您有所帮助这不会像
    SplitViewController
    那样工作必须是您的
    RootViewController
    …这不会像
    SplitViewController
    那样工作必须是您的
    RootViewController
    …我们还可以将splitViewcontroller添加为RootViewController,从登录屏幕按钮单击事件使用委托类的对象。关于使用Modelviewcontroller的安装,如果我错了,请纠正我。是的,这就是我们现在每天都在做的事情。我们还可以从登录屏幕按钮单击事件中添加splitViewcontroller作为Rootviewcontroller,以使用委托类的对象。关于使用Modelviewcontroller的安装,如果我错了,请纠正我。是的,这就是我们现在正在做的所有工作。+1,是的,这一个工作,但是如何通过这样使用来执行推送操作?+1,是的,这一个工作,但是如何通过这样使用来执行推送操作?