PDA

View Full Version : table cell custom drawing problem




chhoda
Nov 25, 2008, 01:24 AM
Hi All,

I am doing a custom cell view in IPhone

my class is inherited from UITableViewCell

I do custom drawing in drawrect: method.

every thing is fine, but while selection of row, the text does not display !. Is there a way i will be able to show up the text after selection drawing happens ?

- (void)drawRect:(CGRect)rect {
// Drawing code
[self.desc drawAtPoint:CGPointMake(0,0) withFont:[UIFont systemFontOfSize:[UIFont systemFontSize]]];

CGRect drawRect = CGRectMake(100, 5, 50, 10);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetRGBFillColor(context, 0.5, 1.0, 0.5, 0.8);

CGContextFillRect(context, drawRect);
}



PhoneyDeveloper
Nov 25, 2008, 09:29 PM
Maybe you want to draw the text after you fill the rect.

chhoda
Nov 27, 2008, 12:18 AM
thanks but i am doing my custom drawing in drawRect method which is being called before the drawing of selected rectangle [which is done automatically, when i select a cell.]

regards
ch

dipaliP
Dec 5, 2008, 05:57 AM
Instead of writing code in drawRect method you can write code in init method of class referenced from UITableViewCell.

So whenever you will create the object of UITableviewCell' class it will create a custom cell for your table view.

And it will work same as default UITableViewCell even if its custom cell. :)

CommanderData
Dec 5, 2008, 08:07 AM
thanks but i am doing my custom drawing in drawRect method which is being called before the drawing of selected rectangle [which is done automatically, when i select a cell.]

regards
ch

Based on the code you presented here, in your drawRect routine you draw some text and then promptly cover it up with a filled rectangle. Or so it seems... That's what PhoneyDeveloper was getting at :)