0
如何將標籤重置爲零,每當用戶點擊圖像時都會計數? 我擁有的當前方法不起作用。IOS - 如何按下按鈕時將數字標籤重置爲零?
這裏是我相信你會需要的代碼:
int number = 0;
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:self.view];
if ([self Intersecting:location :Ball]) {
number++;
[labelCurrentNumber setText:[NSString stringWithFormat:@"%d", number]];
}
}
-(IBAction)startMove {
buttonStart.hidden = YES;
Ball.hidden = NO;
labelEasy.hidden = YES;
buttonBack.hidden = YES;
Destination = CGPointMake(arc4random() % 320, arc4random() % 480);
xamt = ((Destination.x - Ball.center.x)/speed);
yamt = ((Destination.y - Ball.center.y)/speed);
mainTimer = [NSTimer scheduledTimerWithTimeInterval:(0.02) target:self selector:@selector(moveBall) userInfo:nil repeats: YES];
mainInt = 20.00;
timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(countDown) userInfo:nil repeats:YES];
}
請幫我,謝謝你提前。
對不起,我是一個結點。您能否更詳細地向我解釋? –