加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

iphone – UITableView Cell中的图像太大了

发布时间:2020-12-14 17:49:41 所属栏目:百科 来源:网络整理
导读:我在用: NSString *thearticleImage = entry.articleImage; NSRegularExpression *expression = [NSRegularExpression regularExpressionWithPattern:@"(?i)b((?:[a-z][w-]+:(?:/{1,3}|[a-z0-9%])|wwwd{0,3}[.]|[a-z0-9.-]+[.][a-z]{2,4}/)(?:[^s
我在用:

NSString *thearticleImage = entry.articleImage;
    NSRegularExpression *expression = [NSRegularExpression regularExpressionWithPattern:@"(?i)b((?:[a-z][w-]+:(?:/{1,3}|[a-z0-9%])|wwwd{0,3}[.]|[a-z0-9.-]+[.][a-z]{2,4}/)(?:[^s()<>]+|(([^s()<>]+|(([^s()<>]+)))*))+(?:(([^s()<>]+|(([^s()<>]+)))*)|[^s`!()[]{};:'".,<>???“”‘’]))" options:NSRegularExpressionCaseInsensitive error:NULL];
    NSString *someString = thearticleImage;
    self.theurl = [someString substringWithRange:[expression rangeOfFirstMatchInString:someString options:NSMatchingCompleted range:NSMakeRange(0,[someString length])]];
    NSURL *picimage = [NSURL URLWithString:theurl];



    NSData * urlData = [NSData dataWithContentsOfURL: picimage];
    UIImage * imageweb = [UIImage imageWithData: urlData];

    cell.imageView.frame = CGRectMake(0,70,70);
    cell.imageView.image = imageweb;

问题是这会占用整个单元格,我不确定为什么它不仅仅在左侧.

解决方法

我的表格细胞图像遇到了类似的问题.我使用以下内容来缩放图像:

UIImage *imageOne = [UIImage imageNamed:[imagesArray objectAtIndex:indexPath.row]];

cell.imageView.image = [UIImage imageWithCGImage:imageOne.CGImage scale:imageOne.size.width/40 orientation:imageOne.imageOrientation];

注意:考虑上面的“40”表示您希望图像有多少像素宽.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读