【发布时间】:2012-09-17 19:13:35
【问题描述】:
我有两个带有视图的视图控制器。第一个是登录屏幕,第二个是从网络上获取内容(无关)。
我使用了自定义的 segue 动画,并且不得不对 superview 做一些奇怪的事情,以使 sourceViewController.view 位于destinationViewController.view 的“顶部”(视觉上)
我只能假设这就是为什么当我尝试从第二个视图调用 IBAction 方法时它们不会调用。
这里是 segue 类的实现:
- (void) perform {
UIViewController *sourceViewController = (UIViewController *) self.sourceViewController;
UIViewController *destinationViewController = (UIViewController *) self.destinationViewController;
UIView *parent = sourceViewController.view.superview;
[sourceViewController.view removeFromSuperview];
[parent addSubview: destinationViewController.view];
[parent addSubview:sourceViewController.view];
sourceViewController.view.layer.masksToBounds = NO;
sourceViewController.view.layer.cornerRadius = 8; // if you like rounded corners
sourceViewController.view.layer.shadowOffset = CGSizeMake(0,0);
sourceViewController.view.layer.shadowRadius = 10;
sourceViewController.view.layer.shadowOpacity = 1;
destinationViewController.view.frame = CGRectMake(0, 20, destinationViewController.view.frame.size.width, destinationViewController.view.frame.size.height);
sourceViewController.view.frame = CGRectMake(0, 20, sourceViewController.view.frame.size.width, sourceViewController.view.frame.size.height);
[UIView animateWithDuration:.6
delay:0.0
options:UIViewAnimationCurveEaseInOut
animations:^{
sourceViewController.view.frame = CGRectMake(-sourceViewController.view.frame.size.width-10, 20, sourceViewController.view.frame.size.width, sourceViewController.view.frame.size.height);
}
completion:^(BOOL finished){
//[destinationViewController.view removeFromSuperview];
[sourceViewController.navigationController pushViewController:destinationViewController animated:NO];
}];
}
我的问题是,是否可以从其父视图中删除源视图并使用这种破坏方式在第二个视图上调用 IBActions 的方式?
IBAction 方法只是让应用程序崩溃,例如按下按钮。
【问题讨论】:
标签: animation segue ibaction superview