ios UI 之间的切换方法,using prepareForSegue and not
1, use prepareForSegue:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
RWTDetailViewController *detailController =segue.destinationViewController;
RWTScaryBugDoc *bug = [self.bugs objectAtIndex:self.tableView.indexPathForSelectedRow.row];
detailController.detailItem = bug;
}
2, use prepareForSegue:
If you want to programmatically invoke a push segue, you give the segue a "storyboard id" in Interface Builder and then you can:
[self performSegueWithIdentifier:"pushToMyVC" sender:self];
3, without prepareForSegue:
Alternatively, if you don't want to perform the segue, you can instantiate the destination view controller and then manually push to that view controller. All you need to do is to make sure that the destination view controller has its own "storyboard id" in Interface Builder, then you can:
UIViewController *controller = [self.storyboard instantiateViewControllerWithIdentifier:@"DestinationController"];
[self.navigationController pushViewController:controller animated:YES];
You said "push" (and hence I used pushViewController above). If you really meant to "present a modal view controller", then that second line is:
[self presentViewController:controller animated:YES completion:nil];
As you can see, you don't have to useprepareForSegueto push to new scene. You only useprepareForSegueif you want to pass information to the destination view controller. Otherwise it is not needed.
Clearly, if you're not using storyboards (e.g., you're using NIBs), then the process is entirely different. But I assume you're not using NIBs because prepareForSegue is not applicable in that environment. But if you were using NIB, it would be as follows:
SecondViewController *controller = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
[self.navigationController pushViewController:controller animated:YES];
ios UI 之间的切换方法,using prepareForSegue and not的更多相关文章
- ios View之间的切换 屏幕旋转
6.3 View之间的切换 在上面的练习中我们通过移动组件的位置和调整组件的大小来处理横向与纵向的界面布局.但是在界面中有很多组件的时候,对每个组件都进行这样的操作确实是一个麻烦的事情.下面我们看看 ...
- CDB与PDB之间的切换方法
Oracle 12c 开始支持 PLUGGABLE DATABASE,并且提供了一个方法在CDB和PDB之间切换. 1. 使用 show pdbs 可以确认当前有哪些PDB? SQL> show ...
- IOS关于UIViewController之间的切换
IOS关于UIViewController之间的切换 1.NavigationController切换UIViewController的两种方式 方法一右侧进入 1 SecondViewControl ...
- iOS 视图在不同View之间的切换(对于convertRect:函数的一些理解)
可以通过以下函数完成坐标体系在不同View之间的切换,如下面是完成当前View向ParentView坐标的转换(一个矩阵转换)CGRect parentRect = [currentView conv ...
- iOS开发系列--视图切换
概述 在iOS开发中视图的切换是很频繁的,独立的视图应用在实际开发过程中并不常见,除非你的应用足够简单.在iOS开发中常用的视图切换有三种,今天我们将一一介绍: UITabBarController ...
- iOS开发基础-图片切换(4)之懒加载
延续:iOS开发基础-图片切换(3),对(3)里面的代码用懒加载进行改善. 一.懒加载基本内容 懒加载(延迟加载):即在需要的时候才加载,修改属性的 getter 方法. 注意:懒加载时一定要先判断该 ...
- 编程实战——电影管理器之界面UI及动画切换
编程实战——电影管理器之界面UI及动画切换 在前文“编程实战——电影管理器之利用MediaInfo获取高清视频文件的相关信息”中提到电影管理器的目的是方便播放影片,在想看影片时不需要在茫茫的文件夹下找 ...
- iOS开发基础-图片切换(2)之懒加载
延续:iOS开发基础-图片切换(1),对(1)里面的代码进行改善. 在 ViewController 类中添加新的数组属性: @property (nonatomic, strong) NSArra ...
- [iOS]终极横竖屏切换解决方案
[iOS]终极横竖屏切换解决方案 大家的项目都是只支持竖屏的吧?大多数朋友(这其中当然也包括博主),都没有做过横屏开发,这次项目刚好有这个需求,因此把横竖屏相关的心得写成一遍文章供诸位参考. 01.综 ...
随机推荐
- Thrift 应用场景(收集版)
官网: http://thrift.apache.org/ 一些介绍使用的文章: http://www.ibm.com/developerworks/cn/java/j-lo-apachethrift ...
- ubuntu ll命令
用过 Redhat 的朋友应该很熟悉 ll 这个命令,就相当于 ls -l,但在 Ubuntu 中就不行了.严格来说 ll 不是一个命令,只是命令的别名而已.很多 Linux 用户都使用 bash s ...
- 快速使用Log4Cpp
封了一下接口,快速使用. 其他的你都不用管了. 这里封装了需要读取外部conf文件配置输出项.否则可以用getInstance初始化日志类 #include "L4Cpp.h" v ...
- 回顾javase点滴
数据类型 8种基本数据类型和引用类型 数据类型 占用位数 存储方式 最小值 最大值 默认值 byte 8 1+7 -128(-2^7) 127(2^7-1) 0 short 16 1+15 -3276 ...
- Yii 跨域设置
控制器设置: abstract class ControllerBase extends Controller { public function __construct($id, $module, ...
- C#中多线程写DataGridView出现滚动条导致程序卡死(无响应)的解决办法
因为写的程序涉及到多线程维护一个DataGridView,然后蛋疼的发现经常卡死...一开始以为是读写冲突的原因,然后就加了锁,问题依旧...然后发现每次出现滚动条的时候程序才会无响应,所以感觉应该是 ...
- 贴板子系列_1-km算法,匈牙利算法
KM算法 #include <bits/stdc++.h> #define N 1500 #define inf 999999999 using namespace std; ,ny=,k ...
- 第十二周项目一 教师兼干部类】 共建虚基类person
项目1 - 教师兼干部类]分别定义Teacher(教师)类和Cadre(干部)类,采用多重继承方式由这两个类派生出新类Teacher_Cadre(教师兼干部).要求: (1)在两个基类中都包含姓名.年 ...
- Android中JNI编程的那些事儿(1)
转:Android中JNI编程的那些事儿(1)http://mobile.51cto.com/android-267538.htm Android系统不允许一个纯粹使用C/C++的程序出现,它要求必须 ...
- mysql创建自定义函数与存储过程
mysql创建自定义函数与存储过程 一 创建自定义函数 在使用mysql的过程中,mysql自带的函数可能不能完成我们的业务需求,这时就需要自定义函数,例如笔者在开发过程中遇到下面这个问题 mysql ...