[iPhone] Custom background for UITableView

I'm trying to use a custom background image for a UITableView (or more specifically, I'm using a UITableViewController, but I don't think that really matters because I can access its tableView member). I've tried in Interface Builder but can't figure it out. I'm more comfortable doing my views programmatically anyway.
Does anyone know how this is done?
Thanks!

Create a category that extends UINavigationBar:
@implementation UINavigationBar (UINavigationBarCategory)
-(void)setBackgroundImage:(UIImage*)image{
if(image == NULL){ //might be called with NULL argument
return;
UIImageView *aTabBarBackground = [[UIImageView alloc]initWithImage:image];
aTabBarBackground.frame = CGRectMake(0,0,self.frame.size.width,self.frame.size.height);
[self addSubview:aTabBarBackground];
[self sendSubviewToBack:aTabBarBackground];
[aTabBarBackground release];
@end
And call this method from wherever you are initializing your UINavigationController:
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
// Initialization code
// Create the navigation and view controllers
SinglePlayerRootViewController *_rootViewController = [[SinglePlayerRootViewController alloc] initWithStyle:UITableViewStyleGrouped];
UINavigationController *_navigationController = [[UINavigationController alloc] initWithRootViewController:_rootViewController];
self.navigationController = _navigationController;
[_navigationController release];
[_rootViewController release];
// set the image for the top navigation bar
[[navigationController navigationBar] setBackgroundImage:[UIImage imageNamed:@"NavigationBarBackgroundTop.png"]];
// Configure and show the window
[self.view addSubview:navigationController.view];
return self;
I hope this helps!
-ML

Similar Messages

  • I am getting ready to sell a Mac app and I want to know what the specs are to create a custom background for my Mac App?

    I am getting ready to sell a Mac app and I want to know what the specs are to create a custom background for my Mac App?
    Here is a good example of what I am talking about: https://docs.google.com/file/d/0B28kNqQ8gmifRjRHam9wVnlrWG8/edit?usp=sharing

    You need to post your question in the Apple Developer Forums

  • Custom background for UINavigationBar?

    Hi,
    how to set a custom background image for the whole navigation bar of a navigation controller? I can't find any appropriate API method.
    I tried already to mess around with the views of the UINavigationBar to insert my background view - with the result no not-showing buttons and titles :-/
    Also subclassing of UINavigationBar with a new drawRect method does not lead to anywhere - there is simply now way to set the navigation bar for a UINavigationController!
    Any help would be highly appreciated!
    Best regards,
    Matthias Huber

    Create a category that extends UINavigationBar:
    @implementation UINavigationBar (UINavigationBarCategory)
    -(void)setBackgroundImage:(UIImage*)image{
    if(image == NULL){ //might be called with NULL argument
    return;
    UIImageView *aTabBarBackground = [[UIImageView alloc]initWithImage:image];
    aTabBarBackground.frame = CGRectMake(0,0,self.frame.size.width,self.frame.size.height);
    [self addSubview:aTabBarBackground];
    [self sendSubviewToBack:aTabBarBackground];
    [aTabBarBackground release];
    @end
    And call this method from wherever you are initializing your UINavigationController:
    - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
    // Initialization code
    // Create the navigation and view controllers
    SinglePlayerRootViewController *_rootViewController = [[SinglePlayerRootViewController alloc] initWithStyle:UITableViewStyleGrouped];
    UINavigationController *_navigationController = [[UINavigationController alloc] initWithRootViewController:_rootViewController];
    self.navigationController = _navigationController;
    [_navigationController release];
    [_rootViewController release];
    // set the image for the top navigation bar
    [[navigationController navigationBar] setBackgroundImage:[UIImage imageNamed:@"NavigationBarBackgroundTop.png"]];
    // Configure and show the window
    [self.view addSubview:navigationController.view];
    return self;
    I hope this helps!
    -ML

  • Image size and dpi for iDVD menu custom background?

    I created a custom background for my iDVD menu. When showing
    on my TV, part of the words and image is cut off on each side, even after adjusting my tv picture between wide screen and standard screen.
    What is the correct size and dpi to make a photograph to use as a background
    image in the menus? This may have been answered before, so I apologize for posting the same question, if so.

    iDVD will try to downsize the image to work, but your TV often will overscan with the result being edges clipped off. The amount of clipping can vary, so the "TV Safe" settings will typically be the center 80-90% of the image. So, if you add a border that makes the image 10-15% larger, that should display the whole image. For example, if you had a 150 dpi image that was 640x480, you could put a 10% border on it so the final image was 704x528.
    John

  • Custom Background image for UITabBar

    I'm trying to implement a custom background for a UITabBar, I am able to add an image view to the tab bar, but for some reason the image is at the top of the view rather than at the bottom. How do I position it correctly? Here is my code.
    UIImage *image = [UIImage imageNamed:@"tabbarbg.png"];
    UIImageView *theImageView = [[UIImageView alloc] initWithImage:image];
    tabBgView = theImageView;
    [tabBarController.view insertSubview:tabBgView atIndex:1];

    Welcome to the forums gravity98...
    Try using Interface Builder's 'Tab Bar Item Size' insets to stretch it accordingly...push the top/bottom values around to see the effect. Make sure to select/hilight the icon you're targeting first.

  • Custom CSS-Applying selected background for all the cols in the report

    Hi,
    I am trying to set a particular background for all the columns in the report(not for all the projects,so that I can avoid option of manually setting background color for complete report.For this I thought custom CSS is best option.So edited custom.css(C:\OBI11g_Middleware\Oracle_BI1\bifoundation\web\app\res\s_blafp\b_mozilla_4) file with below code and went to the Answers-> Criteria->Choose Column->style-> check "Use Custom CSS Class"->MyCell
    Code used in custom.css
    .MyCell { background-color: #00ff00; font-style:italic; font-weight: bold;}
    Somehow I dont see the background color applied to any of the columns in report.Can anyone had successful attempt of this Custom CSS.Thanks in Advance.

    I am trying both the solutions.
    User 979493,
    I started manually writing the code instead of pasting and almost worked.In the mentioned below paths I dont have custom.css file,so I created one and manually entered below code.But does it work for only that particular column and not for all the columns.Is it supposed to work for all the columns or just that column.
    For example: I have 2 cols in the report,I used "Use Custom CSS Class" -> MyCell for the first column and when I ran results it shows background color for only col1 and not for col2.I thought this feature will apply background color for all the columns in the report.Please correct me if I am wrong.
    custom.css file content:
    .MyCell{background-color: #00ff00;font-style:italic;font-weight:bold;}

  • Is there any Contact Manager or Address Book that I can install on my PC (Windows 7) that when synced to my Iphone that will accept my custom Lables for type of entry, such as you have- Home, Work, then "Private Line" ?

    I am wondering if in fact there is any Contact Manager or Address Book that I can install on my PC running Windows7 that when synced with my 4s that it will retain all my custom lables for phone numbers in Contacts on my iPhone, such as Sandra's Private Line, Cadillac, Bat Phone or what ever?

    Hi sahgin,
    The issue eventually resolved itself, I still don't really know why. I kept up with Windows update, and attempted downloading iTunes again from the Apple website, and it just... worked. It now works fine. I don't know why it took approximately 4 months to work, though.
    I'm sorry I don't have any more helpful information. Posting here was my last resort, and clearly Apple never bothered to reply.

  • Debug background task in custom workflow for PO change

    Hi,
    We are on ECC 6.0 EHP7.
    I have a custom workflow for PO object type(delegated to std object type BUS2012).
    There is a background task which has some custom code written and I need to debug this code.
    Can someone please let me know how to debug a background task?
    Thanks.

    As suggested by ronen we can debug through swo1 but we have to pass values manually for importing parameters, by using sm50 also we can do debug and there is one more way  to debug
    if its custom task change background  task to fore ground and change business object method also change it to fore ground and activate the work flow.
    now change any  po  then it will stop at that step now take that work item id in swi1 and go to swia and execute after putting break point in that method of business object.
    But best way to debug  through infinite loop i.e sm50.
    suri

  • Custom background image for 7942 IP phones on CCM 6.1.2

    All,
    i am unable to create the custom background images for the Cisco 7942 IP phone, i am running a CCM version 6.1.2. I have uploaded the Image files and also the List.xml file, but when i click on custom images i dont see the image that i uploaded and it say "no selection available". And also after i uploaded the files i have restrated the TFTP services.Have attached the images and List.xml files.Please have a look @ them and let me know if i am missing something here.
    Thanks,
    Rohith

    First off, as this is a CUCM question, you'd be better of over in the IP Telephoney forum (
    https://supportforums.cisco.com/community/netpro/collaboration-voice-video/ip-telephony )
    The thing that jumps out at me is the case of the filename. CUCM Runs on Linux which is case sensitive. Try matching the case.
    If that doesn't help, try looking at the phone logs or Wiresharking the phone.
    GTG

  • Can you make custom ringtone for iPhone 4 w/o using iTunes?

    My computer crashed and I had to redownload iTunes and all my music the other day. I plugged my iPhone 4 in to put a custom ringtone I made in iTunes on it and it says it wants to "erase and sync" my phone since it was connected to my old iTunes. Is there a way to fix this or is there a way to make a new custom ringtone for my iphone without using iTunes?

    about backup http://support.apple.com/kb/HT1766
    you're better off creating new ringtones.  Take a look at the first link I gave you, that will answer all your questions.

  • Can we change the Home screen Background for iPhone 5C

    Can we change the Home screen Background for iPhone 5C

    I would assume that the home screen image and the lock screen image would be changed 100% the same way all other iphones change them in the settings

  • OMG...does anyone have a phone number that I can talk to anyone in customer service for an itune dispute on an iphone?

    OMG...does anyone have a phone number that I can talk to anyone in customer service for an itune dispute on an iphone?

    There is no telephone support for itunes. 
    Use the contact link provided in the previous post.

  • Custom Attributes for Scheduled Transactions (Background Jobs)

    Hi,
    I am trying to fetch the custom attributes for scheduled background jobs. Since we are not using the XAcute Queries to run the automatic jobs, we can't use the AUTOBIND property for custom attributes and hence can't fetch them in the scheduled transactions. Is there any way to retrieve the attributes while scheduling a transaction ?
    Thanks,
    Amit Rath

    Hi Amit,
    a way that works: inside your transaction you can call a XML query that reads out the property list for a given user. In the URL of the XML query you can add the user by using the IllumLoginName parameter.
    - create a XML query with the following URL:
    http://<server>:<port>/XMII/PropertyAccessServlet?mode=list&Content-Type=text/xml&IllumLoginName=<User>&IllumLoginPassword=<Password>
    - in your transaction, call the query. You can retrieve the value of the attribute with a XPath expression like this:
    XML_propertyAccessServlet_0.Results{/Rowsets/Rowset/Row[Name='MyAttribute']/Value}
    Interestingly, adding a User / Password in the Scheduler Editor of the job does not work (MII 12.0.2). Maybe this would be also an option for you to try.
    Michael
    Edited by: Michael Otto on Nov 9, 2010 8:27 AM

  • HT201412 while using sometimes my iphone 5stops working and shows the apple logo with white background for 5 seconds and in short time it returns to home screen.please solve it

    while using sometimes my iphone 5stops working and shows the apple logo with white background for 5 seconds and in short time it returns to home screen.please solve it

    Hi there bencong111,
    You may find the troubleshooting steps in the article below helpful.
    iOS: Not responding or does not turn on
    http://support.apple.com/kb/TS3281
    -Griff W. 

  • How to handle too many custom UITableViewCells in UITableView?

    In my iphone app, I need to display many custom rows (maybe thousands or even more) in the UITableView. I add one custom UIView onto each UITableViewCell in "- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath" function, so there will be allocate much memory for the all my custom UIViews. When I add 500 rows into the UITableView, the memory ran out, then the app crashed. I think maybe there is something wrong with my code or design, I don't know how to handle this (thousands custom rows in UITableView). Please help me.... Thanks very much..
    Below is the my code:(if I have thousands of rows, the following code will allocate thousands of CustomViews), is there any way that not allocate so many CustomViews?
    // 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] initWithFrame:CGRectMake(0, 0, 110, 25) reuseIdentifier:CellIdentifier] autorelease] ;
    // Set up the cell...
    CustomView *cellView = [[CustomView alloc]initWithFrame:CGRectMake(1, 1, 108, 24)];
    [cell addSubview: cellView];
    [cellView release];
    return cell;
    }

    Hi,
    well you should add the customView if you need to create a new cell only. Any reused cell will contain this customview allready since you've added it when the cell was created.
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
    cell = [[UITableViewCell alloc] initWithFrame:CGRectMake(0, 0, 110, 25) reuseIdentifier:CellIdentifier] autorelease];
    // Add customView to new cell's only
    CustomView *cellView = [CustomView alloc] initWithFrame:CGRectMake(1, 1, 108, 24)];
    [cell addSubview: cellView];
    [cellView release];
    // Set up the cell...
    return cell;

Maybe you are looking for

  • How do I use my Time Capsule for backup without making it my router?

    I've always used my Time Capsule as my internet router (paired with my Time Warner modem) and I've also used it to back up my computer.   I just got a new modem, it was a nightmare to set up, and it's supposed to have very fast internet.  It's a Time

  • SRM SUS PO Status

    Hi, When the PO status changes to Partially Confirmed state in SUS.Pls advise. Thanks, Venky

  • Migration Assistant - Selecting which applications to transfer

    Hi, I have upgraded to snow leopard and want to use migration assistant to transfer some of the files and apps of my old installation. As far as i can see, there is not much room to maneuver around which applications and files will be transfered. Is

  • Draft 802.11n -- 802.11n firmware upgrade?

    Today's AEBS release is the full 802.11n spec, shouldn't the older draft 802.11n AEBS' be upgradeable as well? side note: I wonder if the "speed" increases on the new AEBS means? Are they just getting closer to the theoretical speeds versus before, o

  • File Transfer Speed Limiter / Queuer for Network?

    Hi, I was wondering if anyone out there knows of an application I can use to queue up file transfers and limit their speed across the network? Preferably though; is there a way I can force priority to be given to the host machine if it needs to use i