0
我已經創建了兩個自定義segue文件,並在兩個,我已經覆蓋了perform
方法。但是,似乎只有在呈現新的UIViewController
時,自定義搜索才起作用,而反過來,不會生成動畫就會解散源UIViewController
。關閉模式視圖控制器與自定義segue
反向定製賽格瑞:
- (void)perform {
UIViewController *sourceViewController = self.sourceViewController;
UIViewController *sourceTabBarController = sourceViewController.parentViewController.parentViewController;
UIViewController *destinationViewController = self.destinationViewController;
UIGraphicsBeginImageContext(destinationViewController.view.bounds.size);
[destinationViewController.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *destinationViewControllerImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageView *destinationViewControllerImageView = [[UIImageView alloc] initWithImage:destinationViewControllerImage];
destinationViewControllerImageView.userInteractionEnabled = YES;
destinationViewControllerImageView.frame = CGRectMake(0.0f, 0.0f, CGRectGetWidth(destinationViewController.view.frame), CGRectGetHeight(destinationViewController.view.frame));
[destinationViewController.view insertSubview:destinationViewControllerImageView atIndex:1];
// Add animations
[UIView animateWithDuration:0.4f
delay:0.0f
options:UIViewAnimationOptionCurveEaseIn
animations:^{
destinationViewControllerImageView.center = CGPointMake(-CGRectGetWidth(destinationViewControllerImageView.frame)/2, -(CGRectGetHeight(destinationViewControllerImageView.frame)/2));
}
completion:nil];
[sourceViewController dismissViewControllerAnimated:NO completion:nil];
}
提前感謝!
好吧,我擔心可能是這種情況!你會怎麼做呢?你會在IBAction中添加解僱代碼,那麼視圖中的uiview動畫代碼塊將會消失嗎?因爲我厭倦了,動畫不運行就被解僱了。順便說一句,我從故事板中刪除了反轉段。 – 2012-08-14 15:58:44
你應該做的是讓'IBAction'調用視圖控制器中的一個方法來解除。在動畫的完成塊中,關閉控制器(因此動畫在控制器被解除之前完成)。 – Dustin 2012-08-14 16:00:41
好了,我有一個'IBAction'容納'[UIView的animateWithDuration:0.5 延遲:0 選項:UIViewAnimationOptionCurveEaseIn 動畫:^ { //我的動畫 } 完成:^(BOOL完成){ [自dismissViewControllerAnimated:NO完成:無]; }];'但是,動畫不會發生,那麼視圖控制器就被立即解散。我誤解了你的評論嗎? – 2012-08-14 16:14:46