UIImageView设置手势无效

在给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");

}

版权声明:本文为博主原创文章,未经博主允许不得转载。

时间: 2024-07-30 20:57:50

UIImageView设置手势无效的相关文章

Include设置layout_*无效解决方法

在include标签中不能省略 layout_width或者layout_height否则设置layout_weight就会无效.如下设置即可 <LinearLayout android:id="@+id/linearLayout1" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="0.0

iOS UIImageView设置为圆形

UIImageView设置为圆形的方法: _Image.layer.masksToBounds = YES; _Image.layer.cornerRadius = self.Image.frame.size.width / 2; 设置加载本地图片的方法: _Image.image = [UIImage imageNamed:@"Image"];//图片“Image”为xcassets里的set名称

以Append方式打开文件,设置偏移量无效

1 #include<stdio.h> 2 3 int main() 4 { 5 FILE * fd = fopen("btoo1.c", "ab+"); 6 fpos_t p ; 7 int fp = fgetpos(fd, &p); 8 printf("bef seek: fgetpos = %ld, ftell = %d\n", p, ftell(fd)); 9 fseek(fd, 12, SEEK_SET); 10 f

UILabel设置圆角无效

原文链接: UILabel设置圆角无效 简书主页:http://www.jianshu.com/users/37f2920f6848 Github主页:https://github.com/MajorLMJ iOS开发者公会-技术1群 QQ群号:87440292 iOS开发者公会-技术2群 QQ群号:232702419 iOS开发者公会-议事区   QQ群号:413102158

iOS XIB使用UIScrollView 设置 contentsize 无效

一问题描述 今天做个需求,后台获取多个对象信息,如果某个对象为nil,则不会显示,当有多个返回对象的适合,界面不能容纳所有的元素,废话这么多,总之是在xib 中使用 UIScrollView,但是问题是.m文件中设置contentsize 无效. 二 问题分析     xib 中勾选了autolayout选项,在autolayout下,iOS计算UIScrollView的contentsize的机制是略有不同.在autolayout中,会在viewDidAppear之前根据subview的con

ie7下设置z-index无效如何解决?

ie7下z-index无效的问题之前做练习的时候遇到过,百度解决掉之后就丢脑后了.今天项目中又发现这个bug,无奈又去百度,这次还是记下来,节省了百度的时间还能小装一把... 需求是这样的: 页面中的两个层默认隐藏,点击这个层的展开图标时要把这个层显示出来,点收起的时候再把这个层隐藏,因为两个层是上下排列,所以点击展开的时候正常的显示应该是这样的,如下(丑)图: 实现的代码我也贴一部分上来,逻辑就是点哪个层,哪个层的z-index值在原来的基础上加高点 $isSales.append($('<e

servlet response设置setCharacterEncoding无效

response的setCharacterEncoding无效,原因有待进一步研究 修改为response.setContentType("text/html;charset=UTF-8");即可 简单总结一下: (1)设置request的编码方式setCharacterEncoding,与request.getParameter有关,与发起申请的页面编码方式一致 (2)设置响应页面的编码方式response.setContentType("text/html;charset

解决embed标签设置z-index无效

今天写静态页面,发现在ie8下embed标签总是显示在最高层,遮住了导航,无论怎么设置z-index的值都无效,几经周折,终于找到了答案. 给embed标签添加个  wmode="transparent" 这个属性,文件就解决了.当然wmode还有个值是Opaque. 网上搜到的介绍是这样的: Opaque 模式 这是一种无窗口模式,在这种情况下flash player没有自己的窗口句柄,这就需要浏览器需要告诉flash player在浏览器的渲染表面绘制的时间和位置.这时flash影

设置placeholder无效解决办法

一.设置placeholder的方法 placeholder属性用来设置控件内部的提示信息 <input type="text" placeholder="请输入用户名"> 改变placeholder的样式: input::placeholder { color: red; font-size: 22px; } 二.各浏览器样式兼容设置 1.针对谷歌浏览器的设置方式: input::-webkit-input-placeholder { color: r