简体   繁体   中英

display view controller before tab bar controller

I'm starting my first application for iphone. I'm using xcode 4.3.3, IOS 5, and the principle of storyboard.

the home screen of the application is a tab bar controller and I want to display a login before the home screen if the user does not logged.

I can not find a solution: if I have to use the file AppDelegate.m with the function didFinishLaunchingWithOptions() or file of my controller with the function viewDidAppear() or something else.

if someone would help me for a solution

Thank you.

you can use another view with login screen and Save Bool value in nsuserdeafault then when app is start check for nsuserdefault and show view according to that.

then after you can call everywhere where you want in delegate.m or viewwillappear.

只需在启动应用程序时创建登录屏幕,并在登录成功后从此处推动标签栏控制器...

It is better to add function in AppDelegate.m to remove unwanted window appearing if not logged in (Your home view will be shown for a moment before redirecting to login page if you write code in ViewDidAppear method).

Another method is add a new view controller and check where to redirect based on log in status from view controller's ViewDidAppear method.

Try using a Modal View Controller, Docs

On didFinishLaunchingWithOptions() or viewWillAppear() try do something like this:

YourViewController *viewController = [[YourViewController alloc] initWithNibName:@"YourViewController" bundle:nil];

viewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
viewController.modalPresentationStyle = UIModalPresentationFormSheet;

//Present as Model view controller  
["presentedViewController" presentModalViewController:viewController animated:YES];

//release it After presenting to it
[viewController release];

Then to remove it call: dismissModalViewControllerAnimated: (docs)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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