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 612165
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:51:49+00:00 2026-05-13T17:51:49+00:00

I have a UITableView in which of course I use some UITableViewCells. Now some

  • 0

I have a UITableView in which of course I use some UITableViewCells. Now some cells have an icon / image which I want to display in front of the text, and some others don’t. I didn’t create the UITableViewCells in Interface Builder, just using the default stuff :

// Customize the appearance of table view cells.
– (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}

// Set up the cell...
switch (indexPath.row) {
    case 0:
        cell.textLabel.text = @"Nearby";
        cell.imageView.image = [UIImage imageNamed:@"marker.png"];
        break;
    case 1:
        cell.textLabel.text = @"Bookmarked";            
        cell.imageView.image = [UIImage imageNamed:@"bookmark.png"];
        break;
    case 2:
        cell.textLabel.text = @"Other";
        break;
    default:
        break;
}

return cell;

}

This seems to be working perfectly, but I have a little issue with the width of the cell.imageView. The icons I’m using seem to have a different width. Some are 21 pixels, others are 25 pixels and in some casts I have no icon at all.

This results in the text for the textLabel to appear at different positions (depending on the width of the imageView).

Now my question is, can I add some code / statement which will make sure that the imageView of my cell is always 30 pixels wide ? Even if there is no image for that imageView ?

Can this be done programatically or will I have to make a Custom Cell in InterfaceBuilder or even create my own UITableViewCell descendant.

Any information on this topic is welcome.

Regards,

Stefaan

  • 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-13T17:51:49+00:00Added an answer on May 13, 2026 at 5:51 pm

    A slightly easier but hackier way:

    1) Make sure your images are the same width. Use an image editor like Acorn to pad the images with a transparent area.

    2) Make a transparent .png 30 (or whatever) pixels wide. Set this as the image on rows with no icon.

    3) There’s no step three!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a UITableView of custom UITableViewCells which looks like this: [ CELL 0
I have an UITableView which includes a list of UITableViewCells. And I set the
I have an array of objects which populate a UITableView . When a user
I have a need to display a UITableView containing a user's account credentials. For
I have an UITableView showing custom view cells that I've designed in interface builder.
I have a UITableView with cells that contain a UISwitch control. It's similar to
I have a custom UITableView cell that sports an Image, and a headline. I
i have a input tag which is non editable, but some times i need
I have a UITableView which I need to update about 2-3 times a second
I have a UITableView which is a read-only, no-scrolling view. It's a subview of

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.