- (IBAction)StartGame:(id)sender
{
MainGameDisplay *secondPage = [[MainGameDisplay alloc] initWithNibName:nil bundle:nil];
[self.view addSubview:secondPage.view];
secondPage.view.frame = CGRectMake(568, 0, 568, 320);//(N = horizontal, N = vertical)
[UIView animateWithDuration:1.0f
animations:^{
//actual frame needed with an animation.
secondPage.view.frame = CGRectMake(0, 0, 568, 320);
}
completion:^(BOOL finished) {
//ENTER HERE ANYTHING TO RUN AFTER ANIMATION IS COMPLETED:
[self presentViewController: secondPage animated:NO completion:NULL];
//This will make the next page load correctly after the transition, otherwise you cannot. interact with anything.
}];
}
これは、ビューに入るのに完全に機能します。がないと、新しいページを操作できず[self presentViewController: secondPage animated:NO completion:NULL];
、クリックしたボタンでページがクラッシュします。
最初のページに戻って通常どおりに実行すると問題ありませんが、もう一度 StartGame をクリックすると、プログラムがビューを変更してクラッシュします。問題は行[self.view addSubview:secondPage.view];
にあります。これをコメントアウトすると、プログラムはクラッシュしませんが、ビューを変更しても遷移せず、すぐに表示されます。
トランジションは、ランドスケープモードでもかなりラグがあり、グリッチがありますが、ポートレートでは完璧です.