Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6558843
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:14:57+00:00 2026-05-25T13:14:57+00:00

I am trying to customize the UITableViewCell below for an iPhone app in a

  • 0

I am trying to customize the UITableViewCell below for an iPhone app in a grouped table view. What I would like to do is have the image width take up the whole cell minus padding (280) and the height variable based on the image size.

Currently I am using SDWebImage to asynchronously download remote images. This may not be the correct thing to do in this case. I am also having trouble figuring out how to give the custom cell the image on initialization. The image URL is stored in self.beerPhoto in the DetailViewController.

I have searched for this a number of ways and have not found exactly what I am looking for. The closest was this: How to scale a UIImageView proportionally, but this method seems to require the cell to have the image at initialization, as I tried to make this code work but setting the image after initialization left a blank cell.

The current code includes constants I set to approximate an image in portrait orientation. In reality some of the images are portrait and some are landscape orientation.

Please let me know if there’s anything additional you need to know.

Header for custom UITableViewCell:

#import <UIKit/UIKit.h>


@interface BeerDetailHead : UITableViewCell {
    UILabel *beerName;
    UIImageView *beerImage;
}

@property(nonatomic, retain)UILabel *beerName;
@property(nonatomic, retain)UIImageView *beerImage;

@end

Relevant portion of implementation for custom UITableViewCell

#import "BeerDetailHead.h"


@implementation BeerDetailHead

@synthesize beerName, beerImage;

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
        //beerName = [[UILabel alloc]init];
        //beerName.textAlignment = UITextAlignmentLeft;
        //beerName.font = [UIFont systemFontOfSize:14];
        beerImage = [[UIImageView alloc]init];
        //[self.contentView addSubview:beerName];
        [self.contentView addSubview:beerImage];
    }
    return self;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    CGRect contentRect = self.contentView.bounds;
    CGFloat boundsX = contentRect.origin.x;
    CGRect frame;
    frame= CGRectMake(boundsX+10 ,10, 280, 375);
    beerImage.frame = frame;
}

DetailViewController’s cellForRowAtIndexPath

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *SimpleTableIdentifier = @"SimpleTableIdentifier";

    NSArray *listData =[self.tableContents objectForKey:
                        [self.sortedKeys objectAtIndex:[indexPath section]]];

    NSLog(@"listData = %@", listData);

    NSUInteger row = [indexPath row];

    if ([self.sortedKeys objectAtIndex:[indexPath section]] == @"header"){
        static NSString *headerTableIdentifier = @"HeaderTableIdentifier";
        BeerDetailHead * headerCell = (BeerDetailHead*)[tableView
                                                        dequeueReusableCellWithIdentifier: headerTableIdentifier];

        if(headerCell == nil) {

            headerCell = [[[BeerDetailHead alloc] initWithFrame:CGRectZero reuseIdentifier:headerTableIdentifier] autorelease];                 
        }

        headerCell.beerName.text = [listData objectAtIndex:row];
        [headerCell.beerImage setImageWithURL:[NSURL URLWithString:self.beerPhoto]
                       placeholderImage:[UIImage imageNamed:@"placeholder.png"]];
        //NSLog(@"frame = %@", headerCell.beerImage.frame);

        return headerCell;
    }
    else{
        //use standard UITableViewCell
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T13:14:57+00:00Added an answer on May 25, 2026 at 1:14 pm

    Implement tableView:heightForRowAtIndexPath: delegate method and return calculated height for each row from this method.
    After loading each image call reloadData on your tableView OR if you want to animate changes call:

    [self.tableView beginUpdates];
    [self.tableView endUpdates];
    

    Also, you might want to combine several sequence height updates into one. I would use I little delay to perform this:

    // triggerUpdates calls the above code
    [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(triggerUpdates) object:nil];
    [self performSelector:@selector(triggerUpdates) withObject:nil afterDelay:0.1];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to customize a table view to display a feed of youtube videos
I am trying to customize the font of a UITableViewCell using the following code
I am trying to customize the installation of JasperServer. I have downloaded the source.
I am trying to create a UITableViewCell with multiple labels. I have been trying
I'm trying to customize the UIImagePickerController for iPhone right now. I could modify the
I am trying to create 3 table view cells using code (w/o nib). I
I am having a table view with default UITableViewCell of style UITableViewCellStyleValue2. I just
I am trying to customize date from my RSS feed to display like how
I am trying to customize the moreNavigationController in a UITabBarController. I have been reading
I am trying to customize text in google maps info window. I have a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.