扫码关注官方订阅号
小伙看你根骨奇佳,潜力无限,来学PHP伐。
如果prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?)里没有做判断肯定是找不到segue "hello" 的。
segue "hello"
你不能自己创建 segue ,只能在 storyboard 中连线并指定 identifier
我仔细的看了文档并且试了下 只有在重写了 perform:_ 方法或者用带perform:_ 方法的闭包的便利构造器才可以通过identifier 来访问 segue也就是说只有在实现了上述方法segue才会被真正完全示例化来使用
perform:_
identifier
两种方法:1.写一个UIStoryboardSegue的子类,然后重写其 perform 方法.2.使用
convenience init(identifier identifier: String?, source source: UIViewController, destination destination: UIViewController, performHandler performHandler: () -> Void)
方法来创建 UIStoryboardSegue.
一个 obj-c的示例如下:
UIViewController * toVC = [[UIViewController alloc] init]; UIStoryboardSegue * segue = [UIStoryboardSegue segueWithIdentifier:@"hello" source:self destination:toVC performHandler:^{ [self presentViewController: toVC animated: YES completion: NULL]; }]; [segue perform];
另外,既然用纯代码了,或许不使用 segue,直接跳转,会更方便些.
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
如果prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?)里没有做判断肯定是找不到
segue "hello"的。你不能自己创建 segue ,只能在 storyboard 中连线并指定 identifier
我仔细的看了文档并且试了下
只有在重写了
perform:_方法或者用带perform:_方法的闭包的便利构造器才可以通过identifier来访问 segue也就是说只有在实现了上述方法segue才会被真正完全示例化来使用
两种方法:
1.写一个UIStoryboardSegue的子类,然后重写其 perform 方法.
2.使用
方法来创建 UIStoryboardSegue.
一个 obj-c的示例如下:
另外,既然用纯代码了,或许不使用 segue,直接跳转,会更方便些.