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];
}];
}];
しかし、問題はアプリケーションのローテーションです。アプリケーション whiteView を回転させた後、detailViewController の背後でウィンドウの中央に配置されません。
どうすればこの問題を解決できますか?