assigning to uiimagepickercontrollerdelegate from incompatible type
I have added a UIImagePickerController to a UIViewController. I have assigned the UIImagePickerControllerDelegate to that UIViewController.
When I try to do
myPicker.delegate = self;
Xcode gifts me with this message: warning: assigning to id from incompatible type 'RootViewController *'
Then I added the UINavigationControllerDelegate protocol to the same UIViewController and the error message vanished.
So, do I have to add both protocols to the ViewController when I add a UIImagePickerController?
if the UIImagePickerController is a subclass of UINavigationController as stated on the docs, shouldn't this be automatic? Why do I have to add its parent's delegate protocol and not just the UIImagePickerControllerDelegate protocol?
Is this a bug or am I missing something?
thanks.
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.
assigning to uiimagepickercontrollerdelegate from incompatible type的更多相关文章
- Assigning to 'id<UINavigationControllerDelegate,UIImagePickerControllerDelegate> _Nullable' from incompatible type 'InfchangeVC *const __strong'
出现 Assigning to 'id<UINavigationControllerDelegate,UIImagePickerControllerDelegate>' from inco ...
- iOS Assigning to 'id<XXXDelegate>' from incompatible type 'BViewController *__strong'
在使用代理的时候, BViewController *BVC = [[BViewController alloc]init]; self.delegate = BVC; 出现这样的警告Assignin ...
- Xcode工程编译错误之iOS开发之Sending '__strong typeof (xxx)' (aka 'xxxx *__strong') to parameter of incompatible type 'id<xxx>'
iphone开发出现警告: Sending '__strong typeof (xxx)' (aka 'xxxx *__strong') to parameter of incompatible ty ...
- Sending 'ccColor4B' (aka 'struct_ccColor4B') to parameter of incompatible type
今天遇到了如下的一个错误, Sending 'ccColor4B' (aka 'struct_ccColor4B') to parameter of incompatible type CiColor ...
- 警告:Assigning to 'id<Delegate>' from incompatible type 'ViewController *const_st
原因: 你自己写了代理,设置了 delegate = self.但是self 没有遵守这个协议 只需要遵守这个协议就可以消除警告.
- Xcode编译警告Assigning to 'id<XXXDelegat> ——Nullable' from incompatible type 'XXXView *const_strong'
编译报警告 可能是 自定义分类使用协议时出现与父类协议的冲突 解决方法如下:
- Assigning to "id<CALayerDelegate> _Nullable" from incompatible type "ZXCapture *const __strong" 的警告提示信息
该警告提示信息,是说,设置了代理对象,但是并没有继承它的代理.下图中,可以看出,警告信息提示我们没有继承“CALayerDelegate”的代理. 解决方法,很简单,(在 @interface 文件中 ...
- 学习笔记之IKM C++ 11
https://github.com/haotang923/interview/tree/master/IKM Q1. If most of the calls to function foo() b ...
- TensorFlow Python3.7环境下的源码编译(三)编译
这里要为仅支持 CPU 的 TensorFlow 构建一个 pip 软件包,需要调用以下命令: $ bazel build --cxxopt="-D_GLIBCXX_USE_CXX11_AB ...
随机推荐
- INDEX && PRIMARY KEY && UNIQUE KEY
When I have do some sql tody, some confusion come up to me. Its about the index && PRIMARY K ...
- loj2001 「SDOI2017」树点涂色
there #include <iostream> #include <cstdio> using namespace std; int n, m, dfn[100005], ...
- 关于dispatch_sync死锁问题
首先,我们来看下下面一个例子: 代码:(串行队列里同步线程嵌套) NSLog(@"haha"); dispatch_queue_t queue = dispatch ...
- cobbler常用目录/命令(三)
常用目录: /var/www/cobbler/ks_mirror/ cobbler distro文件目录 /var/lib/tftpboot/pxelinux.cfg/d ...
- TOJ1017: Tour Guide
描述 You are working as a guide on a tour bus for retired people, and today you have taken your regu ...
- NOJ——1627Alex’s Game(II)(尺取)
[1627] Alex’s Game(II) 时间限制: 2000 ms 内存限制: 65535 K 问题描述 Alex likes to play with one and zero as you ...
- C# ORM框架
SQLSUGAR http://www.codeisbug.com/Doc/8/1159 附带mysql工具类,最优使用上面sqlsugar using System; using System.Co ...
- java maven项目testng执行时使用的是test-classes下的文件,共享main下方resource的配置
在pom.xml中配置 <build> <testResources> <testResource> <directory>${project.base ...
- winform控件大小改变是防止背景重绘导致的闪烁(转载)
在工作中需要做一个伸缩控件,这个自定义控件继承于Panel.这个伸缩控件分为两个部分,头部是一个自定义组件,伸缩控件的背景为灰色,头部背景要求白色.伸缩控件在点击按钮时会重绘,同时他内部的控件也会重绘 ...
- vim的复制粘贴(包括系统剪贴板)
1.vim常用复制粘贴命令 Vim的复制粘贴命令无疑是y (yank),p(paster),加上yy,P PS: vim有个很有意思的约定(我觉得是一种约定),就是某个命令的大小写都是实现某种功能,只 ...