0

Does [self viewDidAppear:YES]; in the viewDidLoad section of code ensure that the viewDidAppear section of code will run?

Based on feedback from a small subset of our users, it appears for whatever reason that the code I have written in the viewDidAppear section of the main menu's view is not running for them - but it works perfectly well for the majority of users and in all my testing. I'm hoping that by adding [self viewDidAppear:YES]; this will fix the issue for those devices that for some reason were not calling viewDidAppear...

What do you guys think?

Maulik
  • 19,348
  • 14
  • 82
  • 137
RanLearns
  • 4,086
  • 5
  • 44
  • 81

3 Answers3

5

I think that's a horrible idea, personally. I think you're better off finding out WHY viewDidAppear didn't execute for that subset of users. You may only be treating a symptom of a greater problem by just 'fixing' what appears to be wrong.

Richard Brown
  • 11,346
  • 4
  • 32
  • 43
  • any ideas why a viewDidAppear wouldn't execute? – RanLearns Mar 09 '13 at 05:06
  • I'm adding the view with: UIViewController *nextController = [[MainMenuController alloc] initWithNibName:@"MainMenuController" bundle:nil]; [nextController performSelector:@selector(setDelegate:) withObject:self]; [self.view addSubview:nextController.view]; – RanLearns Mar 09 '13 at 05:06
4

ViewDidAppear may not be getting called if its on a view controller that is nested in another view controller and running on an older OS. Before iOS 5, delegate commands did not always get forwarded to child controllers.

Dancreek
  • 9,524
  • 1
  • 31
  • 34
  • I will ask these people if they could tell me which OS they are running... and hopefully everyone will update their devices! – RanLearns Mar 09 '13 at 05:36
  • Got an email reply from one person having this issue that was indeed running 4.3.3 on their iPad 2. Wonder how many users haven't upgraded their OS... – RanLearns Mar 11 '13 at 16:32
  • Based on one user's feedback - this didn't seem to resolve the issue on a pre-iOS 5 device anyways. Several users have now updated their iPads and the issue has been fixed. – RanLearns Mar 23 '13 at 00:58
  • So... any ideas on what's the best workaround? Set a BOOL value to YES in viewDidAppear and then call [self performSelector:@selector(checkIfDidAppear) withObject:nil afterDelay:1.0f]; and then run the viewDidAppear code myself if viewDidAppear had not been called and so the BOOL hadn't been set to YES? Doesn't seem like a great setup... any other ideas? – RanLearns Apr 08 '13 at 00:25
  • In your parent controller's VDA check for iOS5 and if older manually call VDA on your child controllers. – Dancreek Apr 08 '13 at 12:57
1

You should never call delegate methods directly.

Jeff Wolski
  • 6,332
  • 6
  • 37
  • 69