ios学习笔记-Lecture6:Segues

Segues

1、什么是segues?
2、segues有什么用?
segues是一种用于在两种MVC中转换界面的对象。如下:

A UIStoryboardSegue object is responsible for performing the visual transition between two view controllers. In addition, segue objects are used to prepare for the transition from one view controller to another.

3、如何使用segues?
视图跳转的时候,调用prepareForSegue:sender: 方法实现。如视图A->B时,在A的controller中调用该方法。实现过程:
源视图:viewController
目标视图:TextStatsViewController

  • 首先判断seques的identifier是不是自己定义的那个。
  • 其次判断segues的destinationViewController属性是不是要跳转后的视图
  • 最后,上面判断都成功后,就可以对目标视图进行操作了。

代码如下:

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([segue.identifier isEqualToString:@"showStats"]) {
        if ([segue.destinationViewController isKindOfClass:[TextStatsViewController class]]) {
            TextStatsViewController *tvc = (TextStatsViewController *)segue.destinationViewController;
            tvc.textToAnalyze = self.body.textStorage;
        }
    }

}

其他应用小技巧——快捷键操作:
1、Xcode中快速选中顶级视图–shif+control+鼠标左键
2、超类的选择方法:
超类的选择方法

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值