ios开发--通过UIView对象获取该对象所属的UIViewController
来源:互联网 发布:最新流行网络歌曲 编辑:程序博客网 时间:2024/05/29 17:58
通过UIView对象获取该对象所属的UIViewController可以使用UIResponder的nextResponder方法获得,UIView类继承于UIResponder,因此可以直接使用。
根据文档描述,如果View有view controller,则通过nextResponder方法返回,如果没有则返回superview。
下面是英文原文:
if the view has a view controller, it is returned by nextResponder.
If there is no view controller, the method will return the superview
相关代码如下:遍历该View的树形结构,获取到其所属的ViewController
根据文档描述,如果View有view controller,则通过nextResponder方法返回,如果没有则返回superview。
下面是英文原文:
if the view has a view controller, it is returned by nextResponder.
If there is no view controller, the method will return the superview
相关代码如下:遍历该View的树形结构,获取到其所属的ViewController
- (UIViewController*)viewController { for (UIView* next = [self superview]; next; next = next.superview) { UIResponder* nextResponder = [next nextResponder]; if ([nextResponder isKindOfClass:[UIViewController class]]) { return (UIViewController*)nextResponder; } } return nil; }
- [iOS]通过UIView对象获取该对象所属的UIViewController
- ios开发--通过UIView对象获取该对象所属的UIViewController
- 通过UIView对象获取该对象所属的UIViewController
- 通过UIView对象获取该对象所属的UIViewController
- 获取UIView所属的UIViewController
- 通过UIView获取UIViewController
- 通过UIView获取UIViewController
- 通过Graphics对象获取它所属的Control
- iOS 获取view的controller UIView+UIViewController
- iOS根据UIVIew获取当前的UIViewController
- 获取UIView的UIViewController
- 获取uiview的uiviewcontroller
- 获取uiview的uiviewcontroller
- iOS在UIView获取UIViewController
- c++ 获取对象的所属类
- 通过当前UIView获取它对应的UIViewController
- [iOS]获取iOS UI框架中最上层的UIViewController对象
- 判断对象所属的类
- hdu 1022 Train Problem Ⅰ
- 重解析xml后出错:Content is not allowed in trailing section.
- How to Download and Build V8
- WM_CREATE与 WM_PAINT以及WM_INITDIALOG
- 零死角玩转STM32---单通道ADC分析
- ios开发--通过UIView对象获取该对象所属的UIViewController
- Programme Dairy - 自定义UILabel
- css鼠标形状
- 【IDE-Visual Studio】运行出错(chenlu-2):变量未初始化
- javascript获取对象
- 你误把饥渴当成了爱情
- VC++深入详解-第一章学习心得(二)
- 彻底隐藏Nginx版本号的安全性与方法
- android_calendar结构