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");
}
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");
}
相关文章推荐
- easyui-combobox下拉多选
- 短时间大量connect()返回errno 99: cannot assign request address
- iOS AutoLayout报错包含UIView-Encapsulated-Layout-Width
- 黑马程序员——高新技术---Java基础-GUI编程
- UIKit框架-12.UITableView数据刷新
- Ubiquitous Religions(POJ--2524
- Unique Path II
- IOS开发概述-09.UIController和控制器的View
- 【进阶android】Volley源码分析——Volley的工具【StringRequest】
- iOS开发使用Unwind Segue进行返回
- Spark SQL and DataFrame Guide(1.4.1)——之DataFrames
- UIActionSheet
- 云盘+Git GUI云盘文件版本控制
- ios开发之实现长按UITableViewCell弹出UIMenuController
- Android Build属性介绍
- apue 第十一章 线程
- C#中Queue<T>类的使用以及部分方法的源码分析
- C#中Queue<T>类的使用以及部分方法的源码分析
- muduo::BlockingQueue、BoundedBlockingQueue分析
- SPOJ 1771 NQUEEN Yet Another N-Queen Problem