当我点击一个按钮时,我需要在 iphone 中调用触摸事件。我有以下代码没有调用触摸事件
请任何人让我知道如何解决这个问题。
按钮代码如下。
-(无效)方法{
BottomView = [[UIView alloc] 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)];
}
}
上面的方法是调用和
-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{ NSLog(@"是"); }
当我单击刷新按钮时没有调用。
谁能帮我吗。提前致谢