我已经构建了一个应用程序,用户可以在其中按下按钮并在每次点击时获得许多文本响应。在 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