0

そのため、他のビューに移動するためのボタンを配置したタブバーアプリケーションがあります。

そのため、FirstView.hiにはそれがあります

IBOutlet ContactMainViewController *contactMainViewController;

そしてそれ

-(IBAction)gotoContactMainViewController;

私のFirstView.miには

-(IBAction)gotoContactMainViewController {

    [self presentModalViewController:contactMainViewController animated:YES];
}

そして、.hで作成したSecondViewで

-(IBAction)goBack;

そして.mで

-(IBAction)goBack {

    [self dismissModalViewControllerAnimated:YES];
}

アプリは正しく動作しますが、ボタンをクリックすると緑色の線が表示されます

[self presentModalViewController:contactMainViewController animated:YES];

"Thread 1: Program received signal: "SIGABRT" コンソールで次のように 言います。terminate called throwing an exception[Switching to process 3908 thread 0xb303]

ご協力いただきありがとうございます !

4

3 に答える 3

1

FirstView と ContactMainViewController クラス ファイルの種類は何ですか? それはUIViewControllerまたは単純なUIViewですか?ContactMainViewController は別のクラス ファイルであると仮定します

あなたのfirstView.mで

#import "ContactMainViewController.h"

-(IBAction)gotoContactMainViewController {

    ContactMainViewController _contactMainVC = [[ContactMainViewController alloc]init];

    [self presentModalViewController:_contactMainVC animated:YES];
    [_contactMainVC release];
}

@class ContactMainViewController を追加します。@interface の前のヘッダー。それはそれを行う必要があります。また、警告を回避するために、.m ファイルに #import "ContactMainViewController.h" を必ず追加してください。

于 2011-08-04T18:04:58.137 に答える
0

contactMainViewControllerビューをプッシュする前に割り当てる必要があります。

-(IBAction)gotoContactMainViewController {


if (self.contactMainViewController == nil)
  self.contactMainViewController = [[ContactMainViewController alloc] init];

[self presentModalViewController:contactMainViewController animated:YES];
}
于 2011-08-04T17:26:28.813 に答える