iOS:故事板转场 [英] iOS: Storyboard Segue

查看:29
本文介绍了iOS:故事板转场的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我正在为一个 iPad 应用程序工作,该应用程序在第一个场景中显示幻灯片 - 使用分页 UIScrollView 实现.当我点击幻灯片中的一个页面时,我想推送一个新的 VC(到一个新场景,它应该显示多个缩略图......如果你愿意的话,一种细节层).

Currently I am working for an IPad application which shows a Slideshow on the first scene - realized with a paged UIScrollView. When I click on one page in the slideshow I want to push a new VC (to a new scene, which should present multiple thumbnails... a kind of detail layer if you want so).

我怎样才能通过 segue 做到这一点?目前我只是简单地拉出一个新的 VC 并将 SlideshowVC 与场景中的下一个 VC 连接起来 - 但没有任何反应.我把头围在几个教程上,但大多数都使用一个连接到下一个 VC 的按钮.它是否能够简单地将 SlideshowVC 与下一个 VC 连接,还是我真的需要在整个滚动视图上绑一个按钮并将该按钮与下一个 VC 连接?

How can I do this via segue? Currently I simply pulled out a new VC and connected the SlideshowVC with the the next VC in the scene - but nothing happens. I wrapped my head around a couple of tutorials but most of them use a button which is connected to the next VC. Is it able to simply connect the SlideshowVC with the next VC or do I really need to strap a button over the whole scrollview and connect the button with the next VC?

目前我的场景如下图所示.第一个是 NavVC - 第二个是 SlidehsowVC,第三个是 DetailVC.

Currently my scene look like the following picture. The first one is a NavVC - the second the SlidehsowVC and the third the DetailVC.

推荐答案

如果你不想把 segue 连接到一个按钮上,当你拦截用户交互时,就这样做 -

If you don't want to connect the segue to a button, when you intercept the user interaction, just do this -

[self performSegueWithIdentifier:@"mySegueIdentifier" sender:self];

如果您需要在到达之前进行任何设置,请使用此 -

If you need to set anything up before you get there, use this -

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

    if ([[segue identifier] isEqualToString:@"mySegueIdentifier"]) {
        MyViewController *myViewController = segue.destinationViewController;
        // do something here
    }
}

这篇关于iOS:故事板转场的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆