我有一个像这样生成的视图:
oneView = [[UIView alloc] initWithFrame:CGRectMake(x, y , w, h)];
oneView.tag = i;
UITapGestureRecognizer* recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTap2:)];
[recognizer setNumberOfTouchesRequired:1];
[oneView addGestureRecognizer:recognizer];
recognizer.delegate = self;
[recognizer release];
- (void)handleSingleTap2:(UITapGestureRecognizer *)recognizer {
int viewID = recognizer.view.tag;
NSLog(@"id : %d", viewID);
}
这可行,但如果我用 UIWebView 或 UIImageView 分配替换 UIView 分配,则不再触发触摸事件。
我怎样才能使它工作?