简体   繁体   English

如何在使用故事板时将navigationcontroller推送动画设置为“否”

[英]How to set navigationcontroller push animation to “No” while using storyboard

I am using storyboard for a navigation based iphone application. 我正在使用故事板进行基于导航的iphone应用程序。 I want viewcontrollers to navigate using "pushviewcontroller" property but at the same time I dont want them to animate. 我希望viewcontrollers使用“pushviewcontroller”属性进行导航,但同时我不希望它们设置动画。 Simply I want to set their Animation property to "NO" 我只想将他们的Animation属性设置为“NO”

How can I do this using storyboard? 我怎么能用故事板做到这一点?

To expand on the answer by @azethoth creating a no animation segue is as easy as: 要扩展@azethoth的答案,创建一个无动画segue就像这样简单:

@interface NoAnimationSegue : UIStoryboardSegue
@end

@implementation NoAnimationSegue    
- (void)perform
{
    [[self.sourceViewController navigationController] pushViewController:self.destinationViewController animated:NO];
}    
@end

As far as I know there is no way to do this declaratively. 据我所知,没有办法以声明的方式做到这一点。 You would either manually call 你可以手动打电话

[sourceController pushViewController:destination animated:NO];

Or, if you're hellbent on using the segue you could create your own subclass of UIStoryboardSegue and implement the perform method to do the above. 或者,如果您对使用segue有所UIStoryboardSegue ,您可以创建自己的UIStoryboardSegue子类并实现perform方法来执行上述操作。 Then in the storyboard you can use a Custom segue and put in the name of your segue subclass. 然后在故事板中,您可以使用自定义segue并输入您的segue子类的名称。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM