Selected UITableViewCell changes background on Scroll?

Sorry, these aren't necessarily the cause for your problem, but start by doing these.

Up vote 0 down vote favorite share g+ share fb share tw.

I have a UITableView with transparent background color, each of its cells have a custom background view, and gray selection style. The selection works fine, but when I select and drag the tableview up or down, the cell changes its background to transparent instead of the custom one. What shall I look to fix it?

EDIT: Source Code as requested by André Morujão - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; RestaurantInfo *restaurantInfo = requestBean. RestaurantArray objectAtIndex:indexPath. Row; UITableViewCell *cell = tableView dequeueReusableCellWithIdentifier:CellIdentifier; if (cell == nil) { cell = UITableViewCell alloc initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier autorelease; } else { cell = nil; cell = UITableViewCell alloc initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier autorelease; } cell setSelectionStyle:UITableViewCellSelectionStyleGray; UIImageView *bgView = UIImageView alloc initWithFrame:CGRectMake(0, 0, 320, 100); bgView setBackgroundColor:UIColor colorWithPatternImage:UIImage imageNamed:@"table_cell_bg.

Png"; cell setBackgroundView:bgView; UILabel *restaurantNameLabel = UILabel alloc initWithFrame:CGRectMake(5, 5, 310, 15); restaurantNameLabel setFont:UIFont boldSystemFontOfSize:16; restaurantNameLabel setText:restaurantInfo. RestaurantName; restaurantNameLabel setBackgroundColor:UIColor clearColor; restaurantNameLabel setUserInteractionEnabled:NO; cell addSubview:restaurantNameLabel; return cell; } objective-c cocoa-touch uitableview iphone-sdk-4.0 uitableviewcell link|improve this question edited May 3 '11 at 9:37 asked Apr 27 '11 at 7:33Syed Absar462214 80% accept rate.

– André Morujão May 3 '11 at 9:11 I have edited the question with the method – Syed Absar May 3 '11 at 9:37.

It'd probably be enough to use a UIView, or even just to apply a backgroundColor.

– Syed Absar May 3 '11 at 10:15 applying a backgroundcolor to cell with pattern image doesn't help too – Syed Absar May 3 '11 at 10:16 I forgot to mention: don't add the UILabel everytime; add it only in the if block and then retrieve it (using viewWithTag: or something similar) and set only the text outside the if block. Also, can you post screenshots of what it looks like before and after? (+ update your code to the latest version) – André Morujão May 3 '11 at 10:29 1 Solved.

I changed cell setBackgroundColor:UIColor colorWithPatternImage:UIImage imageNamed:@"table_cell_bg. Png"; to cell. ContentView setBackgroundColor:UIColor colorWithPatternImage:UIImage imageNamed:@"table_cell_bg.

Png"; and removed the backgroundview thing. – Syed Absar May 3 '11 at 10:36 Thanks dude! :) – Syed Absar May 3 '11 at 10:37.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions