简体   繁体   English

如何在标签栏应用程序启动之前显示登录控制器?

[英]How to show login-controller just before the tab-bar application launch?

Hi, I have done a tab-bar application in iphone/ipad. 嗨,我已经在iphone / ipad中完成了标签栏应用程序。 After completing every thing the client wants a login-controller which the user have to login to enter the first view.The first view a singleview that contains signin button and signup button,this view must be the first view,the user tap the signin it redirect to the signin page means the loginpage. 完成所有操作后,客户端需要一个用户必须登录才能进入第一个视图的登录控制器。第一个视图是包含登录按钮和注册按钮的单一视图,该视图必须是第一个视图,用户点击登录即可重定向到登录页面即登录页面。 After the login the user have to enter the first view of the tabbarapp. 登录后,用户必须进入tabbarapp的第一个视图。 I tried this code in appDidFinishLaunching 我在appDidFinishLaunching尝试了此代码

RootViewController  *log = [[RootViewController alloc] initWithNibName:@"RootViewController" bundle:nil];
    [window addSubview:tabController.view];
    [window addSubview:log.view];
    [window makeKeyAndVisible];

rootviewcontroller is the singin signup button view,i got this view in my app launch.But when i enter the singin ,it wont redirect to the singin or login page.My code for this is rootviewcontroller是singin注册按钮视图,我在应用启动时看到了此视图。但是当我输入singin时,它不会重定向到singin或登录页面。我的代码是

pagesignIn *secondViewController = [[pagesignIn alloc] 
                                               initWithNibName:@"pagesignIn" 
                                               bundle:nil];

    [UIView beginAnimations:@"flipping view" context:nil];
    [UIView setAnimationDuration:1];
    //[UIView setAnimationCurve:UIViewAnimationTransitionFlipFromLeft];
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft 
                           forView:[[self navigationController] view] cache:YES];

    [self.navigationController pushViewController:secondViewController animated:YES ];
    [UIView commitAnimations];

But nothing comes in action, then I put this [self.view removeFromSuperview]; 但是什么都没有做,所以我把这个[self.view removeFromSuperview]; to the above code,now I got the button action but it did-not redirect to the sign-in page,but it redirected to the first page in tab-bar app.What will I do to go tot sign-in page after clicking the sign-in button? 到上面的代码,现在我得到了按钮操作,但是它没有重定向到登录页面,但是重定向到了标签栏应用程序的第一页。单击后如何进入登录页面登录按钮? please help me. 请帮我。 Thanks in advance. 提前致谢。

I guess that your log -ViewController does not have an NavigationController. 我猜你的log -ViewController没有NavigationController。 In your code self.navigationController is nil and all method calls on nil will do nothing. 在您的代码中, self.navigationControllernil并且对nil所有方法调用均self.navigationController

try this: 尝试这个:

RootViewController  *log = [[RootViewController alloc] initWithNibName:@"RootViewController" bundle:nil];
//create a new navigationcontroller
UINavigationController *navVC = [[UINavigationController alloc] initWithRootViewController:log];

[window addSubview:tabController.view];
[window addSubview:navVC.view]; //now add the navigationcontroller instead of the log-vc
[window makeKeyAndVisible];
[navVC release];
[log release];

But I advise you to use a modal-viewcontroller . 但我建议您使用modal-viewcontroller It is much simpler (you dont have to play with subviews of the window for instance) and leads to better understanding of the user that there are two different views. 它要简单得多(例如,您不必使用窗口的子视图),并且可以更好地了解用户的情况,即有两种不同的视图。

You should use modal view controller thats correct. 您应该使用正确的模态视图控制器。

Change iPhone splash screen time 更改iPhone启动画面时间

Refer to this link create your own login view controller class and replace the splash screen object with your login controller object. 参考此链接,创建您自己的登录视图控制器类,并将初始屏幕对象替换为您的登录控制器对象。 After dissmissing the login controller add your tab controller. 解散登录控制器后,添加标签控制器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM