1

In my iPhone app, I have a requirement to present a new UIViewController on viewWillAppear event of a different UIViewController based on the condition.

Actually I am trying to check whether user has logged in or not. I am trying something similar to what is present in eBay's iPhone app. How can I do that?

halfer
  • 19,824
  • 17
  • 99
  • 186
Parth Bhatt
  • 19,381
  • 28
  • 133
  • 216
  • 1
    Maybe you could use a modal view. I don't know the eBay app. Therefore it's just a guess. – dasdom Jan 30 '11 at 13:55

2 Answers2

2

I got the answer. We cannot present a View on -(void)viewWillAppear:(BOOL)animated of a different viewController.

We have to add code for presenting a View on -(void)viewDidAppear:(BOOL)animated method.

halfer
  • 19,824
  • 17
  • 99
  • 186
Parth Bhatt
  • 19,381
  • 28
  • 133
  • 216
0

I am under the impression you have already decided where you want to put the logic to decide whether to show one view or another. viewWillAppear is likely the wrong place because your interface xib file has already been loaded so any way you look at it you'd have to load a new UI at least some of the time.

The best solution is probably for the code that is loading the UIViewController with the logged in UI to figure out if login needs to happen, and load an entirely different UIViewController for login, if that's the case.

The login view controller could then proceed to load the original view controller if login succeeds.

duncanwilcox
  • 3,498
  • 21
  • 18