Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 10-11-2009, 01:57 PM   #16 (permalink)
colionel
Registered Member
 
Join Date: Jul 2009
Posts: 30
colionel is on a distinguished road
Default

Quote:
Originally Posted by tmbg View Post
How would I go about changing its background color without subclassing UITableViewCell?
This is really simple, since OS 3.0 just set the background color of the cell in the willDisplayCell method.
You must not set the color in the cellForRowAtIndexPath.

This works for both the plain and grouped style :

Code:
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
	cell.backgroundColor = [UIColor redColor];
}

P.S: Here the documentation extract for willDisplayCell :

"A table view sends this message to its delegate just before it uses cell to draw a row, thereby permitting the delegate to customize the cell object before it is displayed. This method gives the delegate a chance to override state-based properties set earlier by the table view, such as selection and background color. After the delegate returns, the table view sets only the alpha and frame properties, and then only when animating rows as they slide in or out."

Last edited by colionel; 10-11-2009 at 01:59 PM.
colionel is offline   Reply With Quote
 

» Advertisements
» Stats
Members: 175,282
Threads: 93,959
Posts: 402,306
Top Poster: BrianSlick (7,971)
Welcome to our newest member, kurtwatson
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 09:20 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.