Help with Modal View Controller & Login

China☆狼群 提交于 2020-01-03 00:57:33

问题


I need some help with modal view controllers, as I have not used Modal View Controllers before...

So this is how my application now is...

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.

[_window addSubview:rootController.view];
rootController.selectedIndex =2;
 NSLog(@"Displaying the APP delegate");
[self.window makeKeyAndVisible];
return YES;

}

I have a view for Login, titled LoginViewController . I want this to appear first as the first view, and on clicking the Login button (IBAction), I want it to show rootController.selectedIndex =2;

(Please ignore the login check as of now). I just want the login view controller to appear at first, and dismiss itself if I press Login, and then take the screen to my rootController (which is a UITabBarController)


回答1:


In the viewDidLoad method of the first view in the tabBar present the modal view as follows :

LoginViewController *lvc = [[LoginViewController alloc]initWithNibName:@"LoginViewController" bundle:[NSBundle mainBundle]];

[self presentModalViewController:lvc animated:YES];

[lvc release];

To dismiss the modalView, in the IBAction of the login button just put in the following code :

[self dismissModalViewControllerAnimated:YES];


来源:https://stackoverflow.com/questions/6444107/help-with-modal-view-controller-login

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!