iPhone - UIImagePickerControllerDelegate inheritance

后端 未结 2 1278
青春惊慌失措
青春惊慌失措 2020-12-01 07:32

I have added a UIImagePickerController to a UIViewController. I have also assigned the UIImagePickerControllerDelegate to that U

相关标签:
2条回答
  • 2020-12-01 08:20

    Add these code like below,you can see the warning disappear.

    @interface viewController : UIViewController <UIImagePickerControllerDelegate, UINavigationControllerDelegate> { }
    @end
    

    The Protocol of UIImagePickerController and UINavigationController must be added in your interface, this can make the warning invisible.

    0 讨论(0)
  • 2020-12-01 08:31

    As you noted, UIImagePickerController inherits from UINavigationController. It uses the same delegate property though and doesn't declare a (hypothetical) "imagePickerDelegate" of its own, so your delegate has to conform to both protocols. It makes sense, because you're also assigning the same delegate to the UINavigationController part (that knows nothing about the image picker).

    The API design is a bit questionable here in my opinion, but anyway, all methods in UINavigationControllerDelegate are optional, so it suffices to declare that you conform to the protocol and be done with it.

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