これで問題が発生しました。このコードは、私が望むように動作しません。Xcode:テキストボックスを含むステートメント
if (answer.text == @"text") {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"title" message:@"message" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[alert show];
[alert release];
}else{
UIAlertView *alert1 = [[UIAlertView alloc] initWithTitle:@"title 2" message:@"Title 2" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[alert1 show];
[alert1 release];
}
私の問題は、テキストボックス 'answer'にテキスト 'text'があることです。最初のUIAlertViewはありません。それは常にelse {}の中の1つを実行します。このコードは、ボタンのIBActionにもあります。どんな助けも今良いです。
'[answer.text isEqualToString:@" text "]'アウトレットが正しく接続されていることを確認してください( 'answer'は' IBOutlet'です)。 – Eimantas
も役に立ちました。 – Tyler