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 ...
随机推荐
- poj 2531 分权问题 dfs算法
题意:一个集合(矩阵) m[i][j]=m[j][i]权值,分成两个集合,使其权值最大.注:在同一个集合中权值只能算一个. 思路:dfs 假设都在集合0 遍历 id 的时候拿到集合1 如果与 id 相 ...
- MongoDB学习-->命令行增删改查&JAVA驱动操作Mongodb
MongoDB 是一个基于分布式文件存储的数据库. 由 C++ 语言编写.旨在为 WEB 应用提供可扩展的高性能数据存储解决方案. MongoDB 是一个介于关系数据库和非关系数据库之间的产品,是非关 ...
- bzoj3262陌上花开 三维数点 cdq+树状数组
大早上的做了一道三维数点一道五位数点,神清气爽! 先给一维排序,变成一个奇怪的动态的二维数点(相当于有一个扫描面扫过去,导致一系列的加点和询问) 然后cdq分治,再变回静态,考虑前半段对后半段的影响 ...
- tar.xz结尾的文件的解压缩方法
例如: codeblocks-13.12-1_i386.debian.stable.tar 这个压缩包也是两层压缩,外面是xz压缩方式,里层是tar压缩方式. 解压缩方法: $xz -d ***.ta ...
- 栈的push、pop序列 【微软面试100题 第二十九题】
题目要求: 输入两个整数序列,第一个序列表示栈的压入顺序,请判断第二个序列是否为该栈的弹出顺序.假设压入栈的所有数字均不相等.例如序列1.2.3.4.5是某栈的压栈序列,序列4.5.3.2.1是该压栈 ...
- C语言总结(1)
1scanf( )和printf( )属于系统的函数,分别表示输入和输出. 2.所有C语言的程序只有一个main( )函数,从这里开始运行. 3.程序先执行main( ),调用scanf( ),最后输 ...
- Spring_mvc的搭建以及实现
Spring MVC属于SpringFrameWork的后续产品,已经融合在Spring Web Flow里面.Spring 框架提供了构建 Web 应用程序的全功能 MVC 模块.使用 Spring ...
- java jstl标签
转自:http://blog.csdn.net/liushuijinger/article/details/9143793 JSTL(JSP Standard Tag Library ,JSP标准标签 ...
- POJ——3070Fibonacci(矩阵快速幂)
Fibonacci Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 12329 Accepted: 8748 Descri ...
- [HNOI2006]公路修建问题 (二分答案,并查集)
题目链接 Solution 二分答案+并查集. 由于考虑到是要求花费的最小值,直接考虑到二分. 然后对于每一个二分出来的答案,模拟 \(Kruskal\) 的过程再做一遍连边. 同时用并查集维护联通块 ...