Why does viewDidAppear in UITabBarController exec before the view appears?

前端 未结 2 1448
悲哀的现实
悲哀的现实 2021-01-01 05:42

I have a UITabBarController that nests a UIView-Subclass (ImageViewer) as it\'s third tab.

In this ImageViewer Subclass I call the viewDidAppear method:

2条回答
  •  醉话见心
    2021-01-01 06:15

    From the sound of it, if you are actively calling the method, the device might not have time to actually display the view while it is running the "custom code" in your viewDidAppear method. I that case you should let the program call the viewDidAppear method itself.

    Your program may also be working on other code which would slow down the appearance of the view, this can be solved using timers. i.e. instead of:

    [self otherCode];
    

    you would write:

    [NSTimer scheduledTimerWithTimeInterval:.5 
        target:self 
        selector:@selector(otherCode) 
        userInfo:nil 
        repeats:NO];
    

    you might want to try simply delaying your "custom code" with a timer in this way.

提交回复
热议问题