繁体   English   中英

如何在不使用自定义单元格的情况下在tableviewcell上显示实际图像大小?

[英]How to show actual image size on tableviewcell without using custom cell?

我正在使用cell.imageView.image = [UIImage imageNamed:@"demoImg.png"];在单元格上显示图像cell.imageView.image = [UIImage imageNamed:@"demoImg.png"]; 但在此图中未显示为实际尺寸。

有什么方法可以显示实际尺寸的图像? 在此处输入图片说明

像这张图片显示的是小图片,但实际图片的大小却有所不同,但只有当我单击单元格时,它才会显示实际尺寸

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

    static NSString *cellIdentifier = @"cellIdentifier";

    UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier];

    if(cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];

    }


    if (self.content.count > 0){

        NSDictionary *contentdata = self.content[indexPath.row];

        NSString *title = contentdata[@"description"];
        NSString *imageUrlString = contentdata[@"imageHref"];
       // NSString *description = contentdata[@"title"];

        cell.textLabel.text =  [title isKindOfClass:[NSNull class]] ? @"" : title;  //----- Title
        cell.imageView.image = [UIImage imageNamed:@"demoImg.png"];
       //cell.detailTextLabel.text  =  [description isKindOfClass:[NSNull class]] ? @"" : description;  //----- Description

        cell.contentView.layer.borderColor = [UIColor blackColor].CGColor;
        cell.contentView.layer.borderWidth = 1.0;

不,您无法使用默认单元格执行此操作,您需要一个自定义单元格。 然后,您可以按照自己的喜好进行设置。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM