アプリにscrollviewがあり、2番目にscrollviewの最後のページにスクロールすると、tableviewcontrollerに移動します。
しかし、scrollviewからtableviewコントローラーにジャンプするときに「アニメーションのようなページング」を実現するために、UIStoryboardSegueクラスを拡張し、次のような実行メソッドを実装しました。
- (void) perform {
UIViewController *src = (UIViewController *) self.sourceViewController;
UIViewController *dst = (UIViewController *) self.destinationViewController;
src.view.transform = CGAffineTransformMakeTranslation(0, 0);
dst.view.transform = CGAffineTransformMakeTranslation(320, 0);
[UIView animateWithDuration:0.3
animations:^{
[src presentModalViewController:dst animated:NO];
src.view.transform = CGAffineTransformMakeTranslation(320, 0);
dst.view.transform = CGAffineTransformMakeTranslation(0, 0);
}
];
}
また、ユーザーがUIInterfaceOrientationPortraitオリエンテーションを使用している場合は、チャームのように機能します。しかし、UIInterfaceOrientationLandscapeLeftまたはrightに切り替えると、動作させることができません。
私がここで基本的にやりたいのは、上記のコードが通常の向きで機能するように、テーブルビューコントローラーが左側からメイン画面に(デフォルトの動作であるため、上または下からではなく)入ってくるように見えるようにセグエを実行することです。私は解決策がこのようなものになると想像しました:
- (void) perform {
UIViewController *src = (UIViewController *) self.sourceViewController;
UIViewController *dst = (UIViewController *) self.destinationViewController;
if ([[UIDevice currentDevice]orientation] == UIInterfaceOrientationLandscapeLeft || [[UIDevice currentDevice]orientation] == UIInterfaceOrientationLandscapeRight){
}else{
src.view.transform = CGAffineTransformMakeTranslation(0, 0);
dst.view.transform = CGAffineTransformMakeTranslation(320, 0);
}
[UIView animateWithDuration:0.3
animations:^{
[src presentModalViewController:dst animated:NO];
if ([[UIDevice currentDevice]orientation] == UIInterfaceOrientationLandscapeLeft || [[UIDevice currentDevice]orientation] == UIInterfaceOrientationLandscapeRight){
}else{
src.view.transform = CGAffineTransformMakeTranslation(320, 0);
dst.view.transform = CGAffineTransformMakeTranslation(0, 0);
}
}
];
}
しかし、私が助けを借りるのはもっと難しいです。
質問の更新:
私は今これを試しました:
- (void) perform {
UIViewController *src = (UIViewController *) self.sourceViewController;
UIViewController *dst = (UIViewController *) self.destinationViewController;
[UIView transitionWithView:src.navigationController.view duration:0.3
options:UIViewAnimationTransitionFlipFromRight
animations:^{
[src.navigationController pushViewController:dst animated:YES];
}
completion:NULL];
}
次のエラーが発生します:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Pushing a navigation controller is not supported'