これはどこにも見つかりません。というわけで、情報をお持ちの方はリンクをお願いします。
View Controllerが1つあり、簡単なゲームのメニューを作成しました。その上にいくつかのボタンがあります。別のView Controllerがあり、いくつかのボタンもあります。
質問は次のとおりです。「カスタムセグエをトリガーするボタンを1つ選択した後、このボタンのアニメーションを(画面から非表示に)どのように実行できますか(アニメーションなし)、別のView Controllerはボタンアニメーションを実行します(画面の境界線から画面)?」
私はこれを次のようにしました:
1) 理論: メニュー ボタンの IBAction を作成し、次にこの IBAction で、performSegueMethod: を呼び出すアニメーション メソッドを呼び出します。この後、viewWillAppear メソッドの新しい VC でアニメーション メソッドを呼び出します (ソース VC のほぼ同じメソッド)。これはすべて機能しますが、滑らかに見えません。このアニメーションの問題は、宛先 VC がソース VC を置き換えるときに発生します。すべてが静的に見える瞬間があり、このアニメーションが開始された後にのみ発生します。この宛先 VC ラグを取り除く方法がわかりません。セグエの前に宛先ビューをロードする必要がありますか? 私はこれをやろうとしましたが、何か間違っているか、役に立たないだけです。
2) 練習:
firstViewController.m:
- (IBAction)newGameSegueButton {
[self menuSlideInDirection:@"CenterToLeft" performingSegueWithIdentifier:@"mode"];
}
-(void)menuSlideInDirection:(NSString *)direction performingSegueWithIdentifier:(NSString *)segueIdentifier
{
[UIView animateWithDuration:0.4 animations:^{
CGPoint newGameButtonCenter;
newGameButtonCenter.x = directionIndex * 160;
newGameButtonCenter.y = self.gameButtonSlide.center.y;
self.gameButtonSlide.center = newGameButtonCenter;
[UIView animateWithDuration:0.3 delay:0.1 options:UIViewAnimationOptionBeginFromCurrentState animations:^{
//some animation too
} completion:nil];
[UIView animateWithDuration:0.2 delay:0.2 options:UIViewAnimationOptionBeginFromCurrentState animations:^{
//animation
} completion:nil];
[UIView animateWithDuration:0.1 delay:0.3 options:UIViewAnimationOptionBeginFromCurrentState animations:^{
//some animation too
} completion:^(BOOL finished){
if(segueIdentifier){
[self performSegueWithIdentifier:segueIdentifier sender:self];
}
}];
}];
}
さて、カスタム セグエ コードは非常に単純です。
-(void)perform
{
UIViewController *src = self.sourceViewController;
UIViewController *dst = self.destinationViewController;
[src.navigationController pushViewController:dst animated:NO];
}
そして私のsecondViewController.m:
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self menuSlideInDirection:@"RightToCenter" performingSegueWithIdentifier:nil];
}
menuSlideInDirection:@"RightToCenter" PerformingSegueWithIdentifier:nil secondViewController で firstView の同じ名前のメソッドと同じ。
セグエ直後の宛先ビュー コントローラの特定のオブジェクトのスムーズなアニメーションを探しています。
すべてが間違っている可能性があり、これを行う別の方法はありますか? (宛先VCのすべてのビューとすべてのコントロールをソースVCに追加し、「宛先VC」をまったく削除することだけを考えています)。
誰かがこれで私を助けてくれることを願っています。