您的位置:首页 > 产品设计 > UI/UE

UIImageView设置手势无效

2015-07-29 16:37 615 查看
在给UIImageView添加手势时,发现不起作用,最终发现是由于我没有设置

User Interaction Enabled和Multiple Touch



NSArray *views = [[NSBundle
mainBundle] loadNibNamed:@"view_register_top"
owner:self
options:nil];

UIView *topView = views.firstObject;

CGRect tframe = CGRectMake(topView.frame.origin.x, statusHeight+navHeight, topView.frame.size.width,topView.frame.size.height);
topView.frame = tframe;

UIImageView *imgHeader = (UIImageView *)[topView
viewWithTag:1];
//创建手势

UILongPressGestureRecognizer *tapImgHeader = [[UILongPressGestureRecognizer
alloc]
initWithTarget:self
action:@selector(headImageClicked:)];
tapImgHeader.minimumPressDuration =
1;
//添加手势
[imgHeader
addGestureRecognizer:tapImgHeader];

[self.view
addSubview:topView];

}

-(void) headImageClicked:(UILongPressGestureRecognizer*)recognizer{

NSLog(@"000000000");
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: