2011-04-08 61 views

回答

0

只需計算變量中的觸摸事件即可。

+1

我認爲OP可能需要比這更多的幫助。 – FreeAsInBeer 2011-04-08 12:28:41

4

下面是做這件事..

UIButton *sampleButton = [UIButton buttonWithType:UIButtonTypeCustom]; 
[sampleButton setFrame:CGRectMake(100, 100, 100, 52)]; 
[sampleButton setTitle:@"Button Title" forState:UIControlStateNormal]; 
[sampleButton setFont:[UIFont boldSystemFontOfSize:20]]; 
[sampleButton setBackgroundImage:[[UIImage imageNamed:@"redButton.png"] stretchableImageWithLeftCapWidth:10.0 topCapHeight:0.0] forState:UIControlStateNormal]; 
[sampleButton addTarget:self action:@selector(buttonPressed) forControlEvents:UIControlEventTouchUpInside]; 
[self.view addSubview:sampleButton]; 

然後在buttonPressed的方法,你可以從中總結出觸摸

-(void)buttonPressed 
{ 
    touchCount++; 
    // Do something or not 
}