Login to main app

假如想象 提交于 2019-12-11 18:34:56

问题


I've already built the main app and the login.

In the appDelegate.m didFinishLaunchingWithOptions, I have

[self.window addSubview:rootController.view];

Which loads up the mainView.

However, I would want it to load up my login first as on a successful login, it will load the rootController (main app) etc.

When I put

[self.validateViewController presentModalViewController:validateViewController animated:YES]; 

and run the app, all I get is a white screen.

What am I doing wrong?

-> The reason I'm trying to do this is because at the moment, I have the rootController load up first but in the viewDidLoad, it loads the Login modal. Because of that, it runs numberOfRowsInSection first and so when I do eventually go into the app after login, it won't show any tableview since it's already gone through numberOfRowsInSection.


回答1:


You need to run presentModalViewController on a controller that has a view being displayed already. Right now you are running presentModalViewController on the view you actually want to present.

You could present the validateViewController after adding the rootController to the app window:

[rootViewController presentModalViewController:validateViewController animated:YES];



回答2:


Just present the login by

[self presentModalViewController:validateViewController animated:YES];


来源:https://stackoverflow.com/questions/6122242/login-to-main-app

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