我在 splitViewDetailController 中有带有 splitViewController 和 tableViewController 的 iPad 应用程序。在单击 tableCell 后,我想显示 detailViewController(使用 UIModalPresentationFormSheet),并带有自定义动画。动画应该是 tableViewCell 的垂直旋转,旋转单元格应该转换为 detailViewController 视图。整个动画应该看起来像 iTunes 播客中的动画。
这是我的动画代码:
CGRect rectInCell = [[self.cellView superview] convertRect:self.cellView.frame toView:cell];
CGRect rectInTableView = [self.tableView rectForRowAtIndexPath:[self.tableView indexPathForCell:cell]];
CGRect rectInSuperview = [self.tableView convertRect:rectInTableView toView:[[[APP_DELEGATE window] subviews] lastObject]];
CGRect imgRect = CGRectMake(rectInSuperview.origin.x+rectInCell.origin.x, rectInSuperview.origin.y+rectInCell.origin.y, rectInCell.size.width, rectInCell.size.height);
self.originalRelativeFrame = imgRect;
self.originalFrame = self.cellView.frame;
self.originalSuperview = self.cellView.superview;
self.originalTransform = self.cellView.transform;
[self.cellView setFrame:imgRect];
if (self.whiteView == nil) {
self.whiteView = [[UIView alloc] init];
[self.whiteView setBackgroundColor:[UIColor whiteColor]];
}
[self.whiteView setFrame:imgRect];
[self.whiteView setAlpha:0];
self.cellView.layer.zPosition = self.cellView.frame.size.width;
self.whiteView.layer.zPosition = self.cellView.frame.size.width;
[[[[APP_DELEGATE window] subviews] lastObject] addSubview:self.whiteView];
[[[[APP_DELEGATE window] subviews] lastObject] addSubview:self.cellView];
CATransform3D rotation = CATransform3DMakeRotation(M_PI/2, 0, 1, 0);
CATransform3D scale = CATransform3DMakeScale(1.5,1.5,1);//(540.0/self.cellView.bounds.size.width, 620.0/self.cellView.bounds.size.height, 1);
CGPoint finCent = CGPointMake([[[[APP_DELEGATE window] subviews] lastObject] bounds].size.width/2.0, [[[[APP_DELEGATE window] subviews] lastObject] bounds].size.height/2.0);
//(finCent.x > self.cellView.center.x) ? (finCent.x - self.cellView.center.x) : (self.cellView.center.x - finCent.x);
CGPoint center = CGPointMake((self.cellView.center.x - finCent.x) / 2.0 ,(self.cellView.center.y - finCent.y )/2.0);
[UIView animateWithDuration:ANIMATION_DURATION_HALF delay:0 options:UIViewAnimationOptionCurveEaseOut
animations:^{
[self.cellView.layer setTransform:CATransform3DConcat(scale, rotation)];
[self.cellView setCenter:CGPointMake(self.cellView.center.x - center.x, self.cellView.center.y - center.y)];
//[self.cellView setAlpha:0];
[self.whiteView.layer setTransform:CATransform3DConcat(scale, rotation)];
[self.whiteView setCenter:CGPointMake(self.whiteView.center.x - center.x, self.whiteView.center.y - center.y)];
//[self.whiteView setAlpha:1];
[self.blackView setAlpha:0.3];
}
completion:^(BOOL finished) {
[self.whiteView setAlpha:1];
[self.cellView setAlpha:0];
[UIView animateWithDuration:ANIMATION_DURATION_HALF delay:0 options:UIViewAnimationOptionCurveLinear
animations:^{
CATransform3D rotation = CATransform3DMakeRotation(M_PI, 0, 1, 0);
CATransform3D scale = CATransform3DMakeScale(540.0/self.cellView.bounds.size.width, 620.0/self.cellView.bounds.size.height, 1);
CGPoint finCent = CGPointMake([[[[APP_DELEGATE window] subviews] lastObject] bounds].size.width/2.0, [[[[APP_DELEGATE window] subviews] lastObject] bounds].size.height/2.0);
[self.cellView.layer setTransform:CATransform3DConcat(scale, rotation)];
[self.cellView setCenter:finCent];
[self.whiteView.layer setTransform:CATransform3DConcat(scale, rotation)];
[self.whiteView setCenter:finCent];
}
completion:^(BOOL finished) {
[self presentModalViewController:self.modalCtrl animated:YES];
}];
}];
但问题是应用程序的轮换。在我的 detailViewController 后面旋转应用程序 whiteView 后,它不会保持在窗口中间。
知道如何解决这个问题吗?