ユーザーがボタンを押して、タップごとに多数のテキスト応答を取得できるアプリを作成しました。10 回の応答の後、ボタンは言うことがなくなったので、ユーザーがタップしてボタン メソッドを再度実行できるように、リセット ボタンを配置しました。この時点で、リセットを行う方法を見つけるのに苦労しています。
@implementation ViewController
@synthesize billLabel, topLabel, bill;
- (void)viewDidLoad
{
[super viewDidLoad];
[bill setHidden:YES];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)button:(id)sender
{
[bill setHidden:NO];
static int counter;
if (counter == 0)
{
billLabel.text = @"text";
}
else if (counter == 1)
{
billLabel.text = @"text2";
}
else if (counter == 2)
{
billLabel.text = @"text3";
}
else if (counter == 3)
{
billLabel.text = @"text4";
}
else if (counter == 4)
{
billLabel.text = @"text5";
}
else if (counter == 5)
{
billLabel.text = @"text6";
}
else if (counter == 6)
{
billLabel.text = @"text7";
}
else if (counter == 7)
{
billLabel.text = @"text8";
}
else if (counter == 8)
{
billLabel.text = @"text9";
}
else if (counter == 9)
{
billLabel.text = @"text10";
}
else if (counter == 10)
{
billLabel.text = nil;
}
counter += 1;
}
- (IBAction)reset:(id)sender
{
}
@end