UIAlertView
でユーザーの選択に基づいてView Controllerを変更しようとしています。私は客観的なCに新しいし、いくつかの問題を抱えています。UIAlertViewでViewController間を移動する
ユーザーが「完了しました」を押すと、アプリは前のView Controllerに戻ることができます。ユーザーが「Scoreboard」を押すと、次のView Controllerに移動することができます。
UIAlertView *jigsawCompleteAlert = [[UIAlertView alloc] //show alert box with option to play or exit
initWithTitle: @"Congratulations!"
message:completedMessage
delegate:self
cancelButtonTitle:@"I'm done"
otherButtonTitles:@"Play again", @"Scoreboard",nil];
[jigsawCompleteAlert show];
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
if (buttonIndex == 0) {
NSLog(@"Cancel Tapped.");
[self.navigationController popViewControllerAnimated:YES];
}
else if (buttonIndex == 1) {
NSLog(@"GO tapped.");
startDate = [NSDate date];
// Create the stop watch timer that fires every 10 ms
stopWatchTimer = [NSTimer
scheduledTimerWithTimeInterval:1.0/10.0
target:self
selector:@selector(updateTimer)
userInfo:nil
repeats:YES];
} else if (buttonIndex == 2) {
NSLog(@"Scoreboard tapped.");
}
}
popViewの部分が動作していて、アプリケーションが1つのView Controllerをナビゲートしています。私は、1つのView Controllerを前進させる方法を知らない。私はそれがpushViewController
と関係があると知っていますが、これを行う方法を詳述している非常に古い矛盾した記事しか見ていません。
ありがとうございました。ありがとうございました。
感謝を。最初にView Controllerをインポートする必要がありますか?私はARCを使用しているので、私が使ったコードは 'UIViewController * ctrl = [[UIViewController alloc] initWithNibName:@" AssignmentViewController3 "bundle:nil]です。 [self.navigationController pushViewController:ctrl animated:YES]; '。私は現在viewcontroller2とviewcontroller3の間にセグを持っていないので、 "シーン到達不能"という警告が出ています。ファイルの名前はAssignmentViewController3.hとAssignmentViewController3.mですが、AssignmentViewController3がNIB名であるかどうかはわかりません。再度ありがとう – garethdn
はい。 #import "AssignmentViewController3.h"行を追加します。代わりにUIViewControllerタイプAssignmentViewController3 – beryllium
私はSIGABRTエラーを取得しています - 'NIBをバンドル内に.....名前AssignmentViewController3'でロードできませんでした。私が今使っているコードは 'AssignmentViewController3 * ctrl = [[AssignmentViewController3 alloc] initWithNibName:@" AssignmentViewController3 "bundle:nil]です。 [self.navigationController pushViewController:ctrl animated:YES]; '。私は明示的にNIB名を設定したことがないので、これが起こっているかどうかは分かりません。 – garethdn