Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

mikezang

macrumors 6502a
Original poster
May 22, 2010
939
41
Tokyo, Japan
I use a NSTimer to set button in highlight mode after touch, is this a easier way and can be run on device?

Code:
-(IBAction) selectFourVoice:(id)sender {
	UIButton *fourVoice = nil;
	
	for (int i = EvenTone; i <= 400; i+=100) {
		fourVoice = (UIButton *)[self viewWithTag:i];
		
		fourVoice.enabled = YES;
		fourVoice.highlighted = NO;
	}
	
	fourVoice = (UIButton *)sender;
	
	for (int i = 1; i <= 4; i++) {
		for (int j = 1 + 100 * i; j <= 100 * i + 10; j++) {
			UIButton *key = (UIButton *)[self viewWithTag:j];
			
			[self setKeyTitle:key forTone:fourVoice.tag];
		}
	}

	[NSTimer scheduledTimerWithTimeInterval:0.0 target:self selector:@selector(timerSetKeyHighlight:) userInfo:fourVoice repeats:NO];
}

-(void) timerSetKeyHighlight:(NSTimer *)timer {
	UIButton *fourVoice = (UIButton *)[timer userInfo];
	fourVoice.highlighted = YES;
	fourVoice.enabled = NO;	
}
 

Attachments

  • SnapShot 2010-11-03 at 22.20.12.jpg
    SnapShot 2010-11-03 at 22.20.12.jpg
    79.9 KB · Views: 161
  • SnapShot 2010-11-04 at 0.10.16.jpg
    SnapShot 2010-11-04 at 0.10.16.jpg
    79.7 KB · Views: 106
  • SnapShot 2010-11-04 at 0.10.21.jpg
    SnapShot 2010-11-04 at 0.10.21.jpg
    79.8 KB · Views: 145
  • SnapShot 2010-11-04 at 0.10.26.jpg
    SnapShot 2010-11-04 at 0.10.26.jpg
    78.6 KB · Views: 155
Just curious, why do you want to keep the button highlighted after the press?
Because the buttons of right are set of the most left buttons.
For example, the top left button is "A", when it is touched, the right buttons will show "An", "Apple", and so on.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.