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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:42:16+00:00 2026-05-28T04:42:16+00:00

Am trying to use 3 images as the background for a cell. a top

  • 0

Am trying to use 3 images as the background for a cell. a top image, a middle (repeating image) and a bottom image. If I use a dequeueReusableCellWithIdentifier then it works fine, however as soon as I start scrolling the table then the images don’t stay inside the cell.

See attached image.

http://theutherfish.co.uk/iosss.png

This is the troublesome code

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cellidentifier"];
if (cell == nil)
{
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"cellidentifier"];
}

This works fine, but I assume it is a memory hog.

UITableViewCell *cell = [[UITableViewCell alloc] initWithFrame:CGRectZero];

What would be the best way to have the best of both worlds? i.e. it working and not being memory intensive.

UPDATE
complete cell for row at index path function

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cellidentifier"];
if (cell == nil)
{
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"cellidentifier"];
}

UIImageView *img1 = [[UIImageView alloc] initWithFrame:CGRectMake(5.0, 0.0, 310.0, 8.0)];
img1.image = [UIImage imageNamed:@"top.png"];

UIImageView *img2 = [[UIImageView alloc] initWithFrame:CGRectMake(5.0, 8.0, 310.0, [PullRefreshTableViewController heightForExpandingCell:text])];
img2.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"middle.png"]];

UIImageView *img3 = [[UIImageView alloc] initWithFrame:CGRectMake(5.0, [PullRefreshTableViewController heightForExpandingCell:text] + 8.0, 310.0, 8.0)];
img3.image = [UIImage imageNamed:@"tempbottom.png"];

[[cell contentView] addSubview:img1];
[[cell contentView] addSubview:img2];
[[cell contentView] addSubview:img3];

return cell;
  • 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-28T04:42:17+00:00Added an answer on May 28, 2026 at 4:42 am

    I would advise using a single stretchable image as your cell background, and adding this in a single imageview (with the appropriate resizing masks) only when creating the cell (I.e. when cell== nil).

    You then adjust the height in the heightForRowAtIndexPath method.

    At the moment you are adding the image views every time a cell is reused, so you end up with dozens of them in each cell, and they are all different heights, so it looks a mess.

    If the stretchable image doesn’t work for you, you should look into creating the image views once only as stated above, and simply adjusting the frames when the cell is re-used.

    Alternatively, since your image looks like nothing more than some grey rounded corners, look into CALayer’s borderWidth, borderColor, borderRadius properties.

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

Sidebar

Related Questions

I am trying to use an image with jquery.corner.js it works fine if I
I'm trying to use GreaseMonkey to replace the background image of a DIV on
I'm trying to use Google's Images API to search an image and put it
I am trying to use a background image using the appearance methods in iOS
I have two images stacked on top of each other and trying to use
I am trying to use it this way: CSS #sprite2 { background: url(../images/csg_sprite.png) no-repeat
I'm trying to use a second background image with a floated div but it
im trying to use a background image within iScroll's javascript. The script seems to
I am trying to use an image I made in photoshop as the background
i'm trying to use 2 background images on a div, im using theese style

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.