IPhone SDK: Add background Image to Tabel cell

Hi all,
I am trying to add a image to the UITableViewCell. For some reason I could not see the image when I called *cell.backgroundView addSubview:imageView*. But if I changed the code to *cell.contentView addSubview:imageView*, I could see the image.
Anyone has idea why?
Thanks in advance.
--------------------Here is my code
CGRect rect;
rect = CGRectMake(0.0, 0.0, 320.0, ROW_HEIGHT);
UITableViewCell *cell = [[[UITableViewCell alloc] initWithFrame:rect reuseIdentifier:identifier] autorelease];
UIImage *image = [[UIImage imageNamed:@"test.png"] retain];
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
imageView.image = image;
imageView.opaque = YES;
[cell.backgroundView addSubview:imageView];
[imageView release];

hi, as far as i know, the property backgroundView does not contain a view at all. If you want to use it, you have to assign a UIView (or subclass) to it.
So you may set the image as the cell's backgroundView with
call.backgroundView = imageView;
or you create a UIView, set it as backgroundView and add the image as subview of the newly created UIView;
cell.backgroundView = [[UIView alloc] initWithFrame:CGRectZero];
[cell.backgroundView adSubView:imageView];

Similar Messages

  • Background Image In Table Cell

    I'm not sure what I'm doing wrong or missing here. This is the first time that I'm using an image as a background. I've made a table with a 100% width with 3 colums and 3 rows. The left and right table cells have been merged and the 3 middle rows are at a width of 938 pixels. I have cropped the images correctly. The right column lines up perfectly, but the left column does not line up like it's supposed to with the image. You can take a look at it by going to http://www.wattsconcepts.com/new
    Here is the code below if anyone wants to take a look at it. Any help in solving this is greatly appreciated. I am using Dreamweaver CS5.5
    Thank you for your time!
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Watts Concepts - Kentucky Web Design - Harrodsburg, Kentucky</title>
    <style type="text/css">
    body {
              margin-left: 0px;
              margin-top: 0px;
              margin-right: 0px;
              margin-bottom: 0px;
              background-color: #000;
              background-image: url();
    </style>
    </head>
    <body>
    <table width="100%" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td rowspan="3" align="left" valign="top" background="images/left-index.jpg"> </td>
        <td width="938" align="center" valign="top"><img src="images/logo-index.jpg" width="938" height="172" /></td>
        <td rowspan="3" align="left" valign="top" background="images/right-index.jpg"> </td>
      </tr>
      <tr>
        <td align="center" valign="top"><img src="images/eye-index.jpg" width="938" height="296" alt="Reach Your Audience Today" /></td>
      </tr>
      <tr>
        <td align="center" valign="top"><img src="images/test-index.jpg" width="938" height="197" /></td>
      </tr>
    </table>
    </body>
    </html>

    Your HTML code should ideally be as follows:
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Watts Concepts - Kentucky Web Design - Harrodsburg, Kentucky</title>
    <style type="text/css">
    body {
    margin-left: 0px;
    margin-top: 0px;
    margin-right: 0px;
    margin-bottom: 0px;
    background-color: #000;
    </style>
    </head>
    <body>
    <table width="938px" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td width="938" align="center" valign="top"><img src="images/logo-index.jpg" width="938" height="172" /></td>
      </tr>
      <tr>
        <td align="center" valign="top"><img src="images/eye-index.jpg" width="938" height="296" alt="Reach Your Audience Today" /></td>
      </tr>
      <tr>
        <td align="center" valign="top"><img src="images/test-index.jpg" width="938" height="197" /></td>
      </tr>
    </table>
    </body>
    </html>
    Also, you don't need 3 columns for this website. 1 column and 3 rows should do. Also, never use 100% for <table> width. It's bad practice as you're making your site fluid which will render your site to malfunction on some browsers
    And you had the entire 3 sections as 1 image as your CSS body background-image. This is bad practice. Crop only what you want for each section, never give the entire merged site as 1 image.
    Try the code I've given you above and it should work perfect.
    A quick tip: Try learning and using DIV with pure CSS styling instead of tables. Tables are a thing of the past. You could just google it and you have tons of free resources on how to create a site using DIV. Also, there's a beautiful tutorial posted by one of our senior members here: http://www.adobe.com/devnet/dreamweaver/articles/dw_html5_pt2.html that explains how to create HTML5 site with Pure CSS styling using DIV tags.
    Cheers,
    ST

  • How to set background image in a cell?

    I am trying somethign that seems tricky to me...
    The image I am using I faded to a solid color on the bottom
    half. I set the background image to to left and NO REPEAT but when
    the cell grows with content and it stretched beyond the image it
    goes blank underneath. How do I set a background color without
    going over the background image?
    I need them both to be background because I want to use text
    over both.
    Any ideaS?

    Color goes UNDER the background image. Just set it.
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.dreamweavermx-templates.com
    - Template Triage!
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    http://www.macromedia.com/support/search/
    - Macromedia (MM) Technotes
    ==================
    "StarPilot06" <[email protected]> wrote in
    message
    news:eqqve6$341$[email protected]..
    >I am trying somethign that seems tricky to me...
    >
    > The image I am using I faded to a solid color on the
    bottom half. I set
    > the
    > background image to to left and NO REPEAT but when the
    cell grows with
    > content
    > and it stretched beyond the image it goes blank
    underneath. How do I set
    > a
    > background color without going over the background
    image?
    >
    > I need them both to be background because I want to use
    text over both.
    >
    > Any ideaS?
    >

  • How to add background image in ADF?

    How to add my own image background for body using ADF skin components ?
    please share the link if you have any demo code .

    you can use css to customize skin of af:document. something similar to this
    af|document
      background-image: url("../../img/Bluehills.jpg");
    body {
      background: url("/img/body_bg.gif") repeat-x #E0E0E0;
    }if you are using Jdev release 2 then you can simply do this from Skin editor check this link for more info http://download.oracle.com/docs/cd/E18941_01/tutorials/jdtut_11r2_83/jdtut_11r2_83.html
    Edited by: Zeeshan BaiG on Jul 12, 2011 10:33 AM

  • Add BackGround image to TextField control

    Hi,
    i'm using spark list that contains a few TextField controls. how can i add a background image to text field?
    i've tried adding it with the htmlText property but i can i combine it with the current htmlText that contains the current text represented in the control?

    You can add a background image for the whole page, but not for an individual portlet.
    Jerry

  • How to add background image for AdvancedDataGrid in Flash Builder 4

    I want to add a background image for the whole AdvancedDataGrid and
    Application. Can anyone tell me how to do that?
    Thank you.

    you can use css to customize skin of af:document. something similar to this
    af|document
      background-image: url("../../img/Bluehills.jpg");
    body {
      background: url("/img/body_bg.gif") repeat-x #E0E0E0;
    }if you are using Jdev release 2 then you can simply do this from Skin editor check this link for more info http://download.oracle.com/docs/cd/E18941_01/tutorials/jdtut_11r2_83/jdtut_11r2_83.html
    Edited by: Zeeshan BaiG on Jul 12, 2011 10:33 AM

  • Add background image to TopBar

    This topic was brought up at the UI Customization presentation last Wednesday, 7/21, but we ran out of time to discuss...
    I need to add an image to the TopBar, but without a "SetBGImage" type of method, I'm a bit stuck. Can anyone help?

    I've got it! All you have to do is set the table style to the background image. I did something like this:
    String strImageURL = ImgSvrURLHelper.GetInstance().GetCustomURL(m_asOwner.GetIsSecuredSpace(), "portal");
    strImageURL = XPStringUtility.ForceEndsWith(strImageURL, "/") + ImgSvrURLHelper.STR_L4_FILE_TYPE_IMG + "/";
    strImageURL = strImageURL + "green_bg.gif";
    table.SetStyle("background-image:url('"+ strImageURL + "')");

  • Add background image to widget-heading

    How do I add a back ground image to <div class="widget widget-heading-simple widget-body-gray">? When I add it it seems to only show up in Dreamweaver but when I preview it in my browser it wont show.

    Right now it is being defined in your css file called...
    style-default-menus-light.css
    at about line 2513
    If you like, the easiest way to make sure it never gets taken over by an external stylesheet would be to add a style attribute inline to the tag itself...
    <div class="widget widget-heading-simple widget-body-gray" style="background-image:url(yourimage.jpg);">

  • How to add background image for a JInternalFrame Container?

    JInternalFrame fr=new JInternalFrame();
    //we added to desktop,
    Container c=fr.getContentPane();
    //how can we set background image for a internal frame??
    thanks,
    waiting,

    You can let the container's border draw the background image: caution: some will find this image disturbing.
    One nice thing about this solution is that you don't have to subclass any components.

  • [iPhone SDK] Add Photo

    How do I create a view like the New Contact in the iPhone?
    I need to add a button with "Add Photo" option aside with a name cell.
    Exactly like the New Contact in the iPhone.
    See this: http://img237.imageshack.us/my.php?image=jcontactlr5.jpg
    Thanks!

    I do not think the sample code mentioned addresses the poster's question, which incidentally is also my question also. (apologies if I'm missing some part of the sample.)
    To clarify, look at the screenshot he linked to. It appears that the cell is split into two columns- one with text and one with a thumbnail. If you just add an imageview to a single cell beside some text, you won't get this effect. It will look like one continuous cell with two things inside.
    I've seen other 3rd party apps (like Splash ID) do this so I know it is possible. But what is the trick?

  • How to add background image in Pages?

    Pages has consistently proved itself to be very counterintuitive piece of software.  I searched the web for almost an hour without a good solid answer to this question.
    What I want to do:
    1. Add a transparent png as my background, with a cut out center to be used for my content (basically a custom document border).
    2. Have that background automatically replicate itself on every following page.
    3. Be able to type over the entirety of the image if I want, and after reaching the bottom of the page with my text, have Pages automatically create another page for me with the same layout.
    Color me ignorant, but all of that seems impossibly hard to figure out on my own just by poking around / reading tutorials / searching the web for answers.
    Help?

    I'm not sure what you mean by "inspector / object placement." Where do you find that? The object inspector doesn't have any placement options.
    Use the button on the format bar or the wrap inspector as in this screenshot.

  • IPhone SDK save/crop image as tiff?

    Hi,
    Can someone tell me if it is even possible to change the way the images are stored on iPhone or in the minimum return a cropped image in a different format (preferablt tiff) using the SDK classes?
    In simple, all I am trying is, once the user selects an image, I want to be able to convert it to a tiff format?
    Thanks,
    Javid

    Hi - I've found this post that might describe a similar (or same?) issue.
    http://discussions.apple.com/thread.jspa?messageID=7936896&tstart=0
    Hope that helps. You've gotten much farther than me - I'm still trying to figure out how to capture camera images using the SDK for a personal photo application. I couldn't find any mention of it in the UIImage Class Reference. Do you know where I might find docs on how to do it?
    Thanks

  • Add Background Image

    I am using photoshop CS3, I have a nice beach jpg image,and would like to add my photo to it,which is also jpg.Is there anyway that this can be done?Please help me if you can.
    Thanks.Riptorn.

    rip,
    You have to have your Layers Palette open at all times so you know what's going on.
    When you drag the new image over you will see that it doesn't REPLACE the original one; it's a layer above the other one. You need to mask out or remove the parts you want to see through to the background. Not that easy a task, but a common one in Photoshop.
    How you do it depends on what is on the layer on top. What do you have there, figures?
    Look up Extract and Layer Mask.

  • How can I put a background image into the cell of a table using Dreamweaver CC.

    I want to place an image in a table cell and then be able to place editable HTML in the same cell on top of image. I also have Dreamweaver CS6. I can't get either one to do it using solution I found searching on web. Please help ASAP. What am I doing wrong. Example code would be great. Thanks!

    No tables required for any of this.  You simply need a 3-column starter page. 
    In DW, go to File > New > Blank page > HTML. 
    Select a 3-column layout from the 3rd panel.
    Hit Create button.
    Learn to use CSS floats, margins and padding to align elements.  DO NOT use positioning.
    Start with & bookmark these links for future reference:
    CSS Box Model
    http://css-tricks.com/all-about-floats/
    CSS Float
    Floatutorial: Step by step CSS float tutorial
    CSS Margin
    CSS Padding
    Nancy O.

  • Can i add Background Image to JInternalFrame

    Hi all
    i want add a JPG(image) as Backgrounfd of my JInternalFrame after this i have to add all of my components (JButtons,labels) as usual,on the internalframe but these should be apper in jpg image
    thanks
    Mahesh.B

    Hi belette garou
    i had write as u said but its giving error nomethod maching,see the following code
    JInternalFrame addInf = new JInternalFrame("Glass Pane Test",true,true,true,true);
         JDesktopPane desktop = new JDesktopPane();
         JButton label1 = new JButton("Hello World");
         JTextField text = new JTextField("Infovision");
         JFrame frame;
         Image img;
    GlassPaneTest()
              getContentPane().setLayout(null);
    addInf.getContentPane().setLayout(null);
              addInf.setSize(800,600);
              label1.setBounds(200,200,100,20);
              addInf.getContentPane().add(label1);
              text.setBounds(310,200,100,20);
              addInf.getContentPane().add(text);
    img = new javax.swing.ImageIcon("c:/mahi/images/yourrecipe.jpg").getImage();
              addInf.repaint();
              addListener();
    setSize(800,600);
              desktop.add(addInf);
    setContentPane(desktop);                    
              setVisible(true);
              addInf.validate();
         public void paint(Graphics g)
              //super.paintComponent(g);
              addInf.paintComponent(g);
              g.drawImage(img,0,10,null);
         public void addListener()
              label1.addActionListener(new SymAction());
         class SymAction implements ActionListener
              public void actionPerformed(ActionEvent ae)
                   Object object = ae.getSource();
                   if(object == label1)
                   JOptionPane.showMessageDialog(null,
                             "Working",
                             "INFORMATION",
                             JOptionPane.INFORMATION_MESSAGE );
    please do send in detail
    mahesh

Maybe you are looking for

  • Text Appearing as 1-Pixel-Sized Boxes in CS2

    Greetings, I'm having a problem with text inside Photoshop CS2. I've never had this problem before so I'm not sure what's causing it or how to fix it-- obviously. I first noticed this problem when I was doing some work in Photoshop earlier today. I w

  • Table for Stock quantity

    Hi all, Please tell me the table  which has got stock quantity( field in it) for a certain material. Thanks, cs

  • Running with iPod Touch

    Can anyone recommend an armband. I have been running with a Belkin Neopren armband, wich turns out destroyed my Touch (waterdamaged), because my body heat created condensations in the armband. Now a repair is not covered by guarantee and there for co

  • Cannot print PO document from ME9F

    Dear Expert, Hi, I got trouble when printing out the PO document. Here, I have created new PO type (PO Mold) with series number 457xxxxx but the problem is i cant print out the PO 457xxxxx from ME9F. there is a message : no suitable purchasing docume

  • How to attach an attachment to an Invoice

    Hi All, Is there a function module which can attached an attachment to an invoice. Normally when we do MIR4 and get into the display of the invoice then we have a link at the top which allows us to attach the attachment from there. Can we attach the