Terminating app due to uncaught exception 'UIViewControllerHierarchyInconsistency',

后端 未结 5 1892
借酒劲吻你
借酒劲吻你 2020-12-16 14:59

I created a toolbar above the picker with two buttons and worked on ios7, when i run in ios8 crash:

Terminating app two to uncaught exception \'UIVi

5条回答
  •  臣服心动
    2020-12-16 15:45

    I had the same exception on iOS 8 and now fixed as the following codes.

    The point is, you should not add an input view as a child view of view controller's view. (I have no idea why the code worked well in iOS 7 is no longer working well in iOS 8.)

    Before (occurs error)

    UITextField* someTF;
    View* customView;
    UIViewController *mainVC;
    
    [mainVC.view addSubview:customView];
    someTF.inputView = customView;
    

    After (working well)

    UITextField* someTF;
    View* customView;
    UIViewController *mainVC;
    
    //  [mainVC.view addSubview:customView];  <-- delete this line
    someTF.inputView = customView;
    

提交回复
热议问题