【发布时间】:2014-10-31 08:37:24
【问题描述】:
当我们在 Facebook Messenger 上收到消息时,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;
}
【问题讨论】:
-
好的,我会发布代码...
-
嗨!我贴代码!!
标签: ios objective-c uitableview