0
嗨我有一個應用程序UIViewController,支持多點觸控,也有一些按鈕,我需要的是,當用戶雙擊按鈕時,它會打開一個新的視圖,當用戶移動手指在屏幕上它打開了另一種觀點。如果用戶把他的手指在沒有按鍵面積多點觸控和按鈕在同一視圖
的應用程序工作正常,但如果那裏有按鈕,他把他的手指在該地區沒有任何反應
- (void)viewDidLoad
{
[super viewDidLoad];
button = [UIButton buttonWithType:UIButtonTypeCustom];
[button addTarget:self
action:@selector(openPic:)
forControlEvents:UIControlEventTouchDownRepeat];
button.tag = image;
button.frame = CGRectMake(orInc, inc, 70.0, 95.0);
[self.view addSubview:button];
]
-(void) openPic:(id)sender {
UINavigationController *nav=[[UINavigationController alloc]init];
PicController *x=[[PicController alloc]init];
nav.viewControllers=[NSArray arrayWithObject:x];
[self.navigationController pushViewController:x animated:YES];
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
UINavigationController *nav=[[UINavigationController alloc]init];
ViewController *x=[[ViewController alloc]init];
nav.viewControllers=[NSArray arrayWithObject:x];
[self.navigationController pushViewController:x animated:YES];
}
感謝您的回答,如果我設置userInteractionEnabled爲NO按鈕不再工作了,我需要的是,如果用戶雙擊按鈕openPic被調用,如果用戶只是觸摸屏幕甚至在按鈕touchesEnded被調用 – user1208609 2012-02-14 09:59:39