在给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");
}
版权声明:本文为博主原创文章,未经博主允许不得转载。