iOS中的push
2016-05-10 00:00
399 查看
在编程中,我们会遇到这种情况(如图):
在界面上有一个红色的UIView,
红色View上面有一个绿色的UIView,
绿色View上面有一个橙色的UIButton。
在这里,我们如果要点击Button,push到导航的下一页的话,因为Button不在UIViewController上,所以是push不到的,所以要运用下面的方法:
可以把这段代码做成一个类,使用的时候直接拖过去就行了。
在界面上有一个红色的UIView,
红色View上面有一个绿色的UIView,
绿色View上面有一个橙色的UIButton。
在这里,我们如果要点击Button,push到导航的下一页的话,因为Button不在UIViewController上,所以是push不到的,所以要运用下面的方法:
//Button的方法 - (void)btnAction { NSLog(@"哈哈"); NextViewController *nextVC = [[NextViewController alloc] init]; [self.viewController.navigationController pushViewController:nextVC animated:YES]; } //Button方法中调用的方法 - (UIViewController *)viewController { UIResponder *next = self.nextResponder; do { if ([next isKindOfClass:[UIViewController class]]) { return (UIViewController *)next; } next = next.nextResponder; } while (next != nil); return nil; }
可以把这段代码做成一个类,使用的时候直接拖过去就行了。
相关文章推荐
- iOS中的手势
- iOS中的 摇一摇 功能实现
- 带着大家走进iOS单元测试世界
- 文件管理 - 4
- iOS开发总结(下)
- iOS开发获取设备唯一标识、系统版本、应用版本等信息
- iOS开发总结(上)
- iOS的几种本地存储
- iOS开发16进制颜色转10进制RGB颜色
- iOS SEL
- iOS开发- backBarButtonItem 颜色/文字修改
- iOS - (nullable NSString *)stringByAddingPercentEscapesUsingEncoding:(NSStringEncoding)enc 代替方法的使用
- iOS 开发 带区号的城市三级联动(xml解析)
- IOS客户端Coding项目记录(六)
- iOS assign copy retain...含义
- XMPP在iOS上使用-翻译文档
- iOS学习——NSString属性的strong和copy
- iOS获取UDID问题
- [转]iOS学习笔记(2)--Xcode6.1创建仅xib文件无storyboard的hello world应用
- iOS ffmpeg编译,C compiler test failed.问题