dismissModalViewControllerAnimated:ページを閉じませんか?
-
08-07-2019 - |
質問
他のユーザーの問題に関するすべてのアカウントを読みましたが、彼らは私に役立つ結果で終わるとは思わないか、「私はそれを修正しました-助けてくれてありがとう」ソリューションを共有します。表示および非表示にするコードは次のとおりです(すべてのキーオブジェクトはアプリケーションデリゲートのプロパティです。Aboutページを表示してから、アプリケーションに戻ります。どうしたのですか?
現在のモーダルVC(機能):
-(IBAction) showInfoButton: (id) sender {
NSLog(@"%s", __FUNCTION__);
if( aboutViewController == nil ) {
aboutViewController = [[[AboutViewController alloc] initWithNibName:@"About" bundle:[NSBundle mainBundle]] autorelease];
[appDelegate.window addSubview: aboutViewController.view];
}
appDelegate.modalNavigationController = [[UINavigationController alloc] initWithRootViewController:aboutViewController];
[appDelegate.modalNavigationController presentModalViewController:appDelegate.modalNavigationController animated: YES];
}
View Controllerについての私の解雇(動作しません):
-(IBAction) dismissAbout: (id) sender {
NSLog(@"%s", __FUNCTION__ );
[self dismissModalViewControllerAnimated:YES];
}
アニメーション「NO」を試しましたが、違いはありませんでした。私は自分のコードを他の人のコードと一致させようとしましたが、違いはありませんでした。私は輪になって回っていますので、どんな助けでも大歓迎です。
解決
XCodeのフリップサイドコントローラーの既定のテンプレートでは、モーダルコントローラーにデリゲートを追加して、最初のコントローラーに戻る必要があることが示唆されています。最も簡単なのは、xcodeで新しいプロジェクトを作成し、ユーティリティアプリケーションを選択してコードを確認することです。
要するに、これはメイン画面コントローラーのコードであるはずです
- (IBAction)showInfo;
{
InfoScreen * aboutViewController = [[InfoScreen alloc] initWithNibName:@"InfoScreen" bundle:nil];
aboutViewController.delegate =self;
[self presentModalViewController: aboutViewController animated:YES];
[aboutViewController release];
}
- (void)flipsideViewControllerDidFinish;
{
[self dismissModalViewControllerAnimated:YES];
}
そして、これはあなたのアバウト画面の戻るボタンのアクションです:
- (IBAction)done {
[self.delegate flipsideViewControllerDidFinish];
self.delegate = nil;
}
flipsideViewControllerDidFinishなどに応答するようにデリゲートを作成するためのコードには、もう少しあります。明確にしてください。
所属していません StackOverflow