我需要在iPhone上点击按钮时调用iPhone中的触摸事件。 我有下面的代码是不是调用触摸事件单击按钮时,无法在iPhone中调用触摸事件
请任何让我知道如何解决这个问题。
按钮代码如下。
- (无效)方法 {
BottomView = [[UIView的页头] INIT];
btnRefresh = [UIButton buttonWithType:UIButtonTypeCustom]; [btnRefresh setImage:[UIImage imageNamed:@“refresh_icon.png”] forState:UIControlStateNormal]; [btnRefresh setBackgroundImage:[[UIImage imageNamed:@“blue.png”] stretchableImageWithLeftCapWidth:12.0 topCapHeight:0.0] forState:UIControlStateNormal]; [btnRefresh setBackgroundImage:[[UIImage imageNamed:@“ggrey1.png”] stretchableImageWithLeftCapWidth:12.0 topCapHeight:0.0] forState:UIControlStateHighlighted]; [btnRefresh setBackgroundImage:[[UIImage imageNamed:@“ggrey1.png”] stretchableImageWithLeftCapWidth:12.0 topCapHeight:0.0] forState:UIControlStateSelected]; [btnRefresh addTarget:self action:@selector(KeyboardRefresh :) forControlEvents:UIControlEventTouchUpInside];
[btnRefresh setUserInteractionEnabled:YES]; [btnRefresh setMultipleTouchEnabled:YES];
[BottomView addSubview:btnRefresh];
如果(self.isPortrait){
[btnRefresh setFrame:CGRectMake(71, 0, 40, 6)];
[BottomView setFrame:CGRectMake(0, 160, 320, 41)];
}
else{
[btnRefresh setFrame:CGRectMake(94, 0, 61, 8)];
[BottomView setFrame:CGRectMake(0, 123, 480, 41)];
}
}
上述methos正在呼叫和
- (无效)的touchesBegan:(NSSet中*)触摸withEvent:方法(UIEvent *)事件
{ NSLog(@“yes”); }
当我点击刷新butotn时没有调用。
任何人都可以帮助我。 在此先感谢
Thankyou的消息。但我需要调用两者,而且我需要调用触摸移动和触摸结束是否有任何想法。当点击刷新按钮时它必须显示另一个按钮。 – Ganesh 2010-08-21 05:22:38
我不确定,但是,如果你担心按钮,你可能只是想为不同的状态制作多种方法。即UIControlEventTouchUpInside – 2010-08-21 16:22:47