クイズアプリを開発しています。
4択でボタンを押した際に、結果として下からアクションシートを表示させたいとおもっています。
表示させるのは「正解テキストと次へ進む」です。
また、質問の問題ごとに答えが変わってくるので、答えも問題ごとに変えたいです。
今は、アラートで固定の答えのみ表示できるようになっています。
アラート部分のコードは下記です。
問題と答えはテキストでランダムで表示させるようになっています。
ここのコードを貼ってほしいというのがあれば何でも言ってください。
初心者なものでどこのコードを貼るのがわかりやすいのかわからないので…。
よろしくお願い致します。
QuizRunningViewController.m
// 正解アラート
-(IBAction) displayView:(id) sender{
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"【正解】"
message:@"○○○○○○○○○○○"
delegate:self
cancelButtonTitle:@"次へ"
otherButtonTitles:nil];
[alert show];
[alert release];
}
#import <UIKit/UIKit.h>
#import <AudioToolbox/AudioToolbox.h>
// 使用するクラス名を宣言する
@class Quiz;
@interface QuizRunningViewController : UIViewController <UIActionSheetDelegate>
{
Quiz *_quiz; // クイズデータ
UITextView *_questionTextView; // 問題文を表示するテキストビュー
UIButton *_answerButton1; // 選択肢1
UIButton *_answerButton2; // 選択肢2
UIButton *_answerButton3; // 選択肢3
UIButton *_answerButton4; // 選択肢4
SystemSoundID _rightSound; // 正解時の効果音
SystemSoundID _notRightSound; // 不正解時の効果音
UIActionSheet *aActionSheet;
}
// プロパティの定義
@property (retain, nonatomic) Quiz *quiz;
@property (retain, nonatomic) IBOutlet UITextView *questionTextView;
@property (retain, nonatomic) IBOutlet UIButton *answerButton1;
@property (retain, nonatomic) IBOutlet UIButton *answerButton2;
@property (retain, nonatomic) IBOutlet UIButton *answerButton3;
@property (retain, nonatomic) IBOutlet UIButton *answerButton4;
// 選択肢のボタンがタップされたときの処理
- (IBAction)answer:(id)sender;
// 正解アラート
-(IBAction) displayView:(id) sender;
// 次の問題を表示する
- (void)showNextQuiz;
@end