iOS-如何以编程方式禁用unwind segues中的动画?

时间:2016-05-17 17:19:16

标签: ios objective-c animation unwind-segue

我在XCode中创建了一些展开细分,默认情况下它们会附带一个我不想要的动画。在Stack Overflow中进行了一些搜索后,我确实发现应该有一个复选框可以解开以禁用动画,但是Xcode 7中有一些我无法升级的复选框。如何以编程方式禁用展开segue动画?我目前正在运行XCode 6.4。

1 个答案:

答案 0 :(得分:0)

让我们为你<div class="relatively-positioned"> <input id="datetimepicker"> </div> 和你正在解雇FirstController的人命名控制器。此处还有两种情况:一种是SecondController以模态方式呈现,另一种以SecondController方式呈现。

展开segue重置/忽略UINavigationController,必须调整它。在展开时调用modalPresentationStyle的{​​{1}}方法中添加以下内容(我假设您将此方法称为IBAction):

FirstController

prepareForUnwind被解雇为模态时,此部分将起作用。现在,对于两个控制器驻留在- (IBAction)prepareForUnwind:(UIStoryboardSegue *)segue { //TODO: add right condition if you have to UIViewController* secondController = (UIViewController*)segue.sourceViewController; secondController.transitioningDelegate = self; secondController.modalPresentationStyle = UIModalPresentationCustom; } 上的情况,SecondController应该成为其委托:

UINavigationController

这将使UIKit向FirstController询问动画对象以进行后续转换。现在我们应该修改- (void)viewDidLoad { self.navigationController.delegate = self; } 以返回它。

FirstController

FirstController

将相应的代码添加到FirstController.h,因此会为这两种情况返回一些动画对象(介意评论):

@interface FirstController : UIViewController<UIViewControllerTransitioningDelegate, UINavigationControllerDelegate>

现在实现FirstController.m。它应该确认- (id <UIViewControllerAnimatedTransitioning>)animationControllerForDismissedController:(UIViewController *)dismissed { return [Animator new]; } - (id<UIViewControllerAnimatedTransitioning>)navigationController:(UINavigationController *)navigationController animationControllerForOperation:(UINavigationControllerOperation)operation fromViewController:(UIViewController *)fromVC toViewController:(UIViewController *)toVC { //This will disable ALL animations on particular UINavigationController //return nil to use default animation when appropriate return [Animator new]; } 协议。

Animator

UIViewControllerAnimatedTransitioning

Animator.h

@interface Animator : NSObject<UIViewControllerAnimatedTransitioning>

@end

根据此post和此so answer(两者都不是我的)

进行回答
相关问题