dismissmodalviewcontrolleranimated is deprecated first deprecated in ios 6

前端 未结 3 1924
执笔经年
执笔经年 2020-12-25 12:35

I have just updated iOS 6, and run my old code, which is created in iOS 4.3. They give me number of warnings in my application.

I used presentModelViewControll

相关标签:
3条回答
  • 2020-12-25 13:18

    You can use dismissViewControllerAnimated:completion, from the iOS Developer docs

    dismissViewControllerAnimated:completion:

    Dismisses the view controller that was presented by the receiver. - (void)dismissViewControllerAnimated:(BOOL)flag completion:(void (^)(void))completion Parameters

    flag

    Pass YES to animate the transition. completion
    
    A block called after the view controller has been dismissed.
    

    Discussion

    The presenting view controller is responsible for dismissing the view controller it presented. If you call this method on the presented view controller itself, it automatically forwards the message to the presenting view controller.

    If you present several view controllers in succession, thus building a stack of presented view controllers, calling this method on a view controller lower in the stack dismisses its immediate child view controller and all view controllers above that child on the stack. When this happens, only the top-most view is dismissed in an animated fashion; any intermediate view controllers are simply removed from the stack. The top-most view is dismissed using its modal transition style, which may differ from the styles used by other view controllers lower in the stack.

    If you want to retain a reference to the receiver’s presented view controller, get the value in the presentedViewController property before calling this method.

    The completion handler is called after the viewDidDisappear: method is called on the presented view controller. Availability

    Available in iOS 5.0 and later.
    
    0 讨论(0)
  • 2020-12-25 13:21

    Now in ios 6 You can use

    [[Picker presentingViewController] dismissViewControllerAnimated:YES completion:nil];
    

    Instead of

    [[Picker parentViewControl] dismissModalViewControllerAnimated:YES];
    

    and

    [self presentViewController:picker animated:YES completion:nil];
    

    Instead of

    [self presentModalViewController:picker animated:YES];
    
    0 讨论(0)
  • 2020-12-25 13:37

    You should only get the deprecation warning if your deployment target is set to iOS 6. So I would check your deployment target, which is probably set to the Xcode default. Once you change this to 4.3 the deprecation warnings should disappear.

    0 讨论(0)
提交回复
热议问题