Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ios6, UITableViewCell background

I have a trouble with ios6 and UITableViewCell. The backgroundcolor is not set, this is what it used to work in ios5

-(UITableViewCell *)tableView:(UITableView *) tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

UITableViewCell *cell = nil;

NSString *contentForThisRow = [[self myArray] objectAtIndex:[indexPath row]];

cell = [tableView dequeueReusableCellWithIdentifier:@"noticeCell"];

if(cell == nil){
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"noticeCell"];
}


cell.textLabel.text = contentForThisRow;

id path = [NSString stringWithFormat:@"myip%@.jpeg", IDimage];
NSURL *url = [NSURL URLWithString:path];
NSData *data = [NSData dataWithContentsOfURL:url];
UIImage *img = [[UIImage alloc] initWithData:data];

cell.imageView.image = img;


 cell.textLabel.font = [UIFont fontWithName:@"Helvetica" size:15.0];


UIColor *cellBackground = [UIColor colorWithRed:235.0/255.0 green:245.0/255.0 blue:255.0/255.0 alpha:0.25];


cell.accessoryType =  UITableViewCellAccessoryDetailDisclosureButton;
cell.selectionStyle = UITableViewCellSelectionStyleNone;

[cell setBackgroundColor:cellBackground];


return cell;

}

but now I'm not able to set it again!

How should I do this?

Thanks!

like image 471
user1256477 Avatar asked Dec 20 '22 15:12

user1256477


1 Answers

Use

cell.contentView.backgroundColor= [UIColor blueColor];

you may use clear color for cell textlabel background.

It should work. :)

like image 99
iSaalis Avatar answered Dec 28 '22 08:12

iSaalis