2017-06-06 25 views
0

我使用cell.imageView.image = [UIImage imageNamed:@"demoImg.png"];在單元格上顯示圖像,但在此圖像中未顯示其實際尺寸。如何在不使用自定義單元的情況下在tableviewcell上顯示實際圖像大小?

有沒有什麼辦法以實際尺寸顯示圖像? enter image description here

這樣的形象正顯示出小,但實際的圖像是不同的尺寸和更大的,但只有當我對細胞點擊顯示實際尺寸

- (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; 
+0

我不認爲這是可能的。帶圖像的默認單元格用於顯示圖標。 – GeneCode

+0

你必須根據你的原始圖像設置你的單元格的高度和寬度。 –

+0

即使我把高度設置得更大,它不反映在圖像上......只有當我點擊單元格時它會變大 – sss

回答

0

不,你不能使用默認的單元做到這一點,你需要一個自定義的單元格。然後你可以設置你喜歡的方式。

相關問題