UIButton change title on press using a counter
I get an error with the code below.. I'm banging my head against the wall
because I can't figure out why I can't seem to have the message updated
with the number of button presses (a counter) each time you press the
button...
- (IBAction)countButtonTapped:(id)sender {
self.pressCount+=1;
//int count = (int)self.pressCount;
//[self.tapCountButton setTitle:@"I've been tapped %i time(s)!"
forState:UIControlStateNormal];
//[self.tapCountButton setTitle:@"I've hit the main button!"
forState:UIControlStateNormal];
//NSLog(@"I've been tapped %lu time(s)!", (unsigned
long)self.pressCount);
[(UIButton *)sender setTitle:@"I've been tapped %@
time(s)!",self.pressCount forState:UIControlStateNormal];
No comments:
Post a Comment