iOS 7.1 removeFromSuperview crash

后端 未结 9 966
孤街浪徒
孤街浪徒 2021-02-05 13:40

My app didn\'t have any crash until iOS 7.1 came out. Now on any removeFromSuperview method, crash. For example: I got view controllers, and when I

9条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-05 14:27

    UPDATED

    try to do this:

    NSArray *subviews = [NSArray arrayWithArray:[contentVc subviews]];
    for (UIView *subView in subviews)
         [subView removeFromSuperview];
    

    I think that you got the crash beacuse you're trying to fast enumerate an array that has variable length (in fact when you remove a subview, it is removed also from subview array).

    If you want to remove the viewcontroller, just call:

    [contentVc.view removeFromSuperView];
    [contentVc removeFromParentViewController];
    

提交回复
热议问题