首页 > 其他 > 详细

UITapGestureRecognizer 手势传值

时间:2015-09-23 13:21:19      阅读:264      评论:0      收藏:0      [点我收藏+]
- (void)setImageArray:(NSArray *)imageArray
{
    self.count = count;
    
    // 1.添加图片到scrollView中
    for (int i = 0; i < count; i++) {
        
        UIImageView *imageView = [[UIImageView alloc] init];
        
        imageView.tag = i;    // 传值
        
        imageView.userInteractionEnabled = YES;
        UITapGestureRecognizer *singleTap1 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(toSafar:)];
        
        [imageView addGestureRecognizer:singleTap1];
    }
}

- (void)toSafar:(id)sender
{
    UITapGestureRecognizer *tap = (UITapGestureRecognizer *)sender;
    
    int tag = tap.view.tag; // 广告标示
    
    NSLog(@"tap.view.tag: %ld", (long)tap.view.tag);
    
    GBidModel * idModel = self.imageArray[tag];
    
    NSString *urlStr = idModel.pic_link;    // 相应的链接地址
    
    // 用浏览器打开
    [[UIApplication sharedApplication]openURL:[NSURL URLWithString:urlStr]];
}    

 

 

UITapGestureRecognizer 手势传值

原文:http://www.cnblogs.com/lisen-lisen/p/4831779.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!