码迷,mamicode.com
首页 > 其他好文 > 详细

UIImageView设置手势无效

时间:2015-07-29 17:16:49      阅读:160      评论:0      收藏:0      [点我收藏+]

标签:ios手势添加   uiimage长按   手势无效   

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

}



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

UIImageView设置手势无效

标签:ios手势添加   uiimage长按   手势无效   

原文地址:http://blog.csdn.net/chengjiamei/article/details/47129995

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!