开发者

How to switch two nibs from one UIViewController on specific events?

开发者 https://www.devze.com 2023-03-08 19:18 出处:网络
I\'ve created two nibs with different views to manage an user profile page with and without registration.

I've created two nibs with different views to manage an user profile page with and without registration.

In first nib, there is a text and a button asking user to register (and it call a modalViewController to handle registration/login). In the second one, I should present user details (Username, image, etc) only if an user is set (this happens after registration/login procedure).

I would 开发者_Go百科like to change the nib to present on this UIViewController but if I make the check on viewDidLoad, the switch does not work.

I've tried to put the if condition to switch nibs in loadView but I got a black screen on view frame.

Any suggestion ?

thanks


Create a Single UIViewController named ProfileViewController. Create two UIViews as resgisterView and loggedView.

All the controls and logics should be in ProfileViewController. While loading the ProfileViewController use if condition to check the status of user and add the corresponding subview accordingly. Use [self.view addSubView:resgisterView] for this. You can put your if inside the viewdidload.

Just keep a break point and check whether this if is working as expected.


Try to switch the ViewControllers in viewDidAppear rather than viewdidload. I think i will work.

0

精彩评论

暂无评论...
验证码 换一张
取 消