viewDidAppear: is called 2x if child vc is added in applicationDidBecomeActive
| Originator: | nikita.zhuk | ||
| Number: | rdar://14058168 | Date Originated: | 04-Jun-2013 05:44 PM |
| Status: | Open | Resolved: | |
| Product: | iOS SDK | Product Version: | 6.1 |
| Classification: | Serious Bug | Reproducible: | Always |
Summary:
- If view controller containment APIs are used to add a child view controller to UIWindow's root view controller in AppDelegate's applicationDidBecomeActive: callback, the viewDidAppear: callback of child view controller is called twice unless child view controller's addition is delayed by at least 0.1 seconds.
Steps to Reproduce:
- Implement applicationDidBecomeActive: in AppDelegate
- Create a new view controller X
- Add X as child view controller of UIWindow's rootViewController
Expected Results:
- viewDidAppear: callback of X is called once
Actual Results:
- viewDidAppear: callback of X is called twice
Regression:
- On iOS 5.0, viewDidAppear: callback is called once also when child view controller's addition is delayed by 0.0 seconds
- On iOS 6.1, viewDidAppear: callback is called twice when child view controller's addition is delayed by 0.0 seconds
Outputs of a test project ("A" is child VC, "Root" is window's root VC):
==============
Direct call: [self addChildVC:nil]
------------------------------------
iOS 5.0:
2013-06-04 17:28:12.095 ChildViewControllerTest[3833:c07] viewWillAppear: Root
2013-06-04 17:28:12.096 ChildViewControllerTest[3833:c07] addChildVC:
2013-06-04 17:28:12.097 ChildViewControllerTest[3833:c07] viewWillAppear: A
2013-06-04 17:28:12.098 ChildViewControllerTest[3833:c07] viewDidAppear: Root
2013-06-04 17:28:12.099 ChildViewControllerTest[3833:c07] viewDidAppear: A
2013-06-04 17:28:12.099 ChildViewControllerTest[3833:c07] viewDidAppear: A
iOS 6.1:
2013-06-04 17:29:51.691 ChildViewControllerTest[3908:c07] viewWillAppear: Root
2013-06-04 17:29:51.693 ChildViewControllerTest[3908:c07] addChildVC:
2013-06-04 17:29:51.694 ChildViewControllerTest[3908:c07] viewWillAppear: A
2013-06-04 17:29:51.695 ChildViewControllerTest[3908:c07] viewDidAppear: Root
2013-06-04 17:29:51.695 ChildViewControllerTest[3908:c07] viewDidAppear: A
2013-06-04 17:29:51.695 ChildViewControllerTest[3908:c07] viewDidAppear: A
With delay == 0.0 sec
------------------------------------
iOS 5.0:
2013-06-04 17:30:57.187 ChildViewControllerTest[3992:c07] viewWillAppear: Root
2013-06-04 17:30:57.189 ChildViewControllerTest[3992:c07] viewDidAppear: Root
2013-06-04 17:30:57.189 ChildViewControllerTest[3992:c07] addChildVC:
2013-06-04 17:30:57.190 ChildViewControllerTest[3992:c07] viewWillAppear: A
2013-06-04 17:30:57.190 ChildViewControllerTest[3992:c07] viewDidAppear: A
iOS 6.1:
2013-06-04 17:30:37.149 ChildViewControllerTest[3952:c07] viewWillAppear: Root
2013-06-04 17:30:37.152 ChildViewControllerTest[3952:c07] addChildVC:
2013-06-04 17:30:37.153 ChildViewControllerTest[3952:c07] viewWillAppear: A
2013-06-04 17:30:37.153 ChildViewControllerTest[3952:c07] viewDidAppear: Root
2013-06-04 17:30:37.153 ChildViewControllerTest[3952:c07] viewDidAppear: A
2013-06-04 17:30:37.154 ChildViewControllerTest[3952:c07] viewDidAppear: A
With delay == 0.1 sec
------------------------------------
iOS 5.0:
2013-06-04 17:32:01.124 ChildViewControllerTest[4080:c07] viewWillAppear: Root
2013-06-04 17:32:01.126 ChildViewControllerTest[4080:c07] viewDidAppear: Root
2013-06-04 17:32:01.126 ChildViewControllerTest[4080:c07] addChildVC:
2013-06-04 17:32:01.127 ChildViewControllerTest[4080:c07] viewWillAppear: A
2013-06-04 17:32:01.128 ChildViewControllerTest[4080:c07] viewDidAppear: A
iOS 6.1:
2013-06-04 17:31:26.610 ChildViewControllerTest[4041:c07] viewWillAppear: Root
2013-06-04 17:31:26.613 ChildViewControllerTest[4041:c07] viewDidAppear: Root
2013-06-04 17:31:26.713 ChildViewControllerTest[4041:c07] addChildVC:
2013-06-04 17:31:26.713 ChildViewControllerTest[4041:c07] viewWillAppear: A
2013-06-04 17:31:26.714 ChildViewControllerTest[4041:c07] viewDidAppear: A
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!
Sample AppDelegate
https://gist.github.com/anonymous/526aa70785337630bcbc