Objective-C 在View中跳转页面
2016-03-22 00:00
519 查看
摘要: 利用GitController 该方法获取所跳转的父类Controller
#import <UIKit/UIKit.h> @interface ParentClassView : UIView #pragma mark-获取当前view上层的Controller -(UIViewController *)getController; @end
#import "ParentClassView.h" @implementation ParentClassView #pragma mark-获取当前view上层的Controller -(UIViewController*)getController{ id controller = [self nextResponder]; while (![controller isKindOfClass:[UIViewController class]]&&controller!=nil) { controller = [controller nextResponder]; } UIViewController *mainController=(UIViewController*)controller; return mainController; } ParentClassView这个类继承成的是UIView 假如你在这个View中添加了一个按钮这个按钮的功能就是跳转页面 方案一: 在Controller中把自己传到ParentClassView这个View中来解决跳转问题 方案二:我推荐使用的就是GitController方法 使用只需这样写就OK啦 : 如: NewsController * newsController=[NewsController new]; //跳转风格 newsController.modalTransitionStyle=UIModalTransitionStylePartialCurl; //[self getController]--------获得Controller //模态跳转 [[self getController] presentViewController:newsController animated:YES completion:nil];
相关文章推荐
- Objective-C 继承新的认识以及作用
- objective-C CollectionView 加深(添加注册头部View)
- Objective-C探究alloc方法的实现
- Objective-C语法之代码块(block)的使用
- Objective-C语法之代码块(block)的使用
- Object-C高级编程读书笔记(4)——__block说明符
- java学习笔记6--类的继承、Object类
- iOS下Objective-C的图片轮播器分析与源代码分享
- iOS开发实用技巧—Objective-C中的各种遍历(迭代)方式
- 控制gameObject随机旋转的功能代码
- UI - NSObject 映射关系图
- 值得一说的NullObject模式
- iOS安全攻防(二十三):Objective-C代码混淆
- Objective-C学习线路
- Objective-C的发展现状
- Objective-C语言的简介
- jsonarray和jsonobject
- 详解Objective-C的meta-class
- CreateMutex和WaitForSingleObject的用法
- Attempt to mutate immutable object with appendString