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

UITapGestureRecognizer 手势传值

时间:2015-09-23 13:24:32      阅读:125      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!