当我们在Facebook Mesenger上收到消息时,在触摸单元格并查看消息后,该文本在UITableViewCell中变为粗体,然后返回到UITableView,该单元格文本不再为粗体。
如何产生这种行为?
在我的代码下面:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
.
.
.
//Implementation
.
.
.
[[fetchedObjects objectAtIndex:indexPath.row ] setValue:@"1" forKey:@"lido"];
NSError*error;
// Escreve no banco a alteração
[context save:&error];
for (int index = 0; index<[fetchedObjects count]; index++) {
NSLog(@"%@",[[fetchedObjects objectAtIndex:index]valueForKey:@"lido"]);
.
.
.
// Implementation
}
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
.
.
.
//Implmentation
.
.
.
if ([[arrayProcessosLocal objectAtIndex:indexPath.row ] valueForKey:@"lido"] == 1) {
//Torna fonte bold
cell.textLabel.font = [UIFont boldSystemFontOfSize:17];
[cell.textLabel setText:[NSString stringWithFormat:@"%@ - %@", [processosLocal valueForKey:@"processo"],[processosLocal valueForKey:@"data_pdf"]]];
return cell;
}else{
// Exibe a fonte normal caso o valor de "lido" seja 0 (zero)
[cell.textLabel setText:[NSString stringWithFormat:@"%@ - %@", [processosLocal valueForKey:@"processo"], [processosLocal valueForKey:@"data_pdf"]]];
return cell;
}
最佳答案
cell
应该以粗体显示文本。状态更改时,请重新加载cell
,并根据此状态对其进行配置。 关于ios - 如何制作UITableViewCell文本(如iOS版Facebook Messenger)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26670406/