簡體   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