0
我正在开发一个应用程序,以在uitableview中显示推送通知。如果用户尚未显示通知,则打印该通知的单元格具有灰色背景色。 因此,当鉴于如何在选中单元格时编辑uitableviewcell的背景颜色
cellForRowAtIndexPath
方法加载我看,如果没有显示更改单元格的背景为灰色,并离开它默认如果通知显示
if([shown isEqualToString:@"no"]){
cell.contentView.backgroundColor = [UIColor lightGrayColor];
cell.textLabel.backgroundColor = [UIColor lightGrayColor];
cell.detailTextLabel.backgroundColor = [UIColor lightGrayColor];
}
cell.textLabel.text = [NSString stringWithFormat:@"Notifica del %@",data];
cell.detailTextLabel.text = message;
我想改变背景颜色的通知白(相同的风格,当我不碰负载背景颜色),当用户点击细胞
我这样做:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *not = [notification objectAtIndex:indexPath.row];
NSArray *stringArray = [not componentsSeparatedByString:@"---"];
NSString *message = [stringArray objectAtIndex:0];
NSString *data = [stringArray objectAtIndex:1];
NSString *shown = [stringArray objectAtIndex:2];
UITableViewCell *cell = (UITableViewCell *)[tableView cellForRowAtIndexPath:indexPath];
cell.contentView.backgroundColor = [UIColor whiteColor];
cell.textLabel.backgroundColor = [UIColor whiteColor];
cell.detailTextLabel.backgroundColor = [UIColor whiteColor];
UIAlertView *popUp = [[UIAlertView alloc] initWithTitle:[NSString stringWithFormat:@"Notifica del %@",data] message:message delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[popUp show];
[popUp release];
}
结果是所有的单元格变成完全白色(隐藏文本)和警报出现,但是当我点击另一个单元格时,第一次点击变得像以前一样,新单元格变成完全白色..我该怎么做?你可以帮我吗?