iOS: different addSubview behavior between iOS 4.3 and 5.0

前端 未结 7 2101
长发绾君心
长发绾君心 2021-01-30 11:32

while coding in iOS 4.3 before, I found while add a view controller\'s view to another view with [superview addSubView:controller.view], the controller instance wil

7条回答
  •  萌比男神i
    2021-01-30 11:35

    It is iOS5 behavior:
    viewWillAppear, viewDidAppear, ... are executed automatically after addSubView: for iOS5.
    So for iOS5 no need to execute manually those methods as need for iOS<5.0.

    The fix may be:

    if ([[UIDevice currentDevice].systemVersion doubleValue] < 5.0) {
    ...execute viewWillAppear or other
    }
    

提交回复
热议问题