0
두 개의 사용자 정의 segue 파일을 만들었으며 두 가지 모두에서 perform
메서드를 오버로드했습니다. 그러나 사용자 지정 segue는 새로운 UIViewController
을 표시 할 때만 작동하고 그 반대의 경우에는 애니메이션을 적용하지 않아서 소스 UIViewController
을 닫는 것처럼 보입니다.사용자 정의 segue가있는 모달보기 컨트롤러 닫기
역 사용자 정의 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 애니메이션 코드 블록을 추가 하시겠습니까? 그것이 내가 피곤하고 애니메이션이 실행되지 않는 것을 그냥 해산시키는 것입니다. 그건 그렇고, 나는 스토리 보드에서 반전 섹 그를 제거했다. –
당신이해야 할 일은'IBAction' 호출을 해제 할 뷰 컨트롤러의 메소드입니다. 애니메이션 완료 블록에서 컨트롤러를 닫습니다 (컨트롤러가 닫히기 전에 애니메이션이 완료됩니다). 0.5 지연 : 0 옵션 : UIViewAnimationOptionCurveEaseIn 애니메이션 :^{ // 내 애니메이션 } 완료 :^(BOOL 완료) { [자기 – Dustin
좋아, 그래서'[UIView의 animateWithDuration 주택'IBAction'이 dismissViewControllerAnimated : 완료 없음 : 없음]; }]; '그러나 애니메이션이 발생하지 않으면 뷰 컨트롤러가 바로 해제됩니다. 나는 당신의 의견을 오해 했습니까? –