TableView Cell Background Image Problem

Discussion in 'iOS Programming' started by loon3y, Dec 29, 2011.

  1. loon3y macrumors 65816

    loon3y

    Joined:
    Oct 21, 2011
    #1
    I've been trying to add a background image to my table view cells, so each cell has an image of a brand and when they click on it it'll go to another view controller to show the products of that brand.


    but I've been on this for hours now and i can't figure it out heres my code:


    Code:
     UIView *cellBackView = [[[UIView alloc] initWithFrame:CGRectZero] autorelease];
        cellBackView.backgroundColor = [UIColor colorWithPatternImage: [UIImage imageNamed:@"background2.png"]];
        cell.backgroundView = cellBackView;
    
    


    this code worked on my other tableview (was just trying things out) and it worked only when i scanned an item to add to the tableview. but it did not show up when the app loads, which is what i need.
     
  2. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #2
    Why not just?:
    Code:
    cell.backgroundColor = [UIColor colorWithPatternImage: [UIImage imageNamed:@"background2.png"]];
     
  3. jnoxx macrumors 65816

    jnoxx

    Joined:
    Dec 29, 2010
    Location:
    Aartselaar // Antwerp // Belgium
    #3
    Don't you have a XIB for your custom UITableViewCells, or are they standard, if they are, then Dejo has your magic answer
     

Share This Page