0
J'ai un UITableView, j'ai défini la couleur de la première ligne comme Vert.Conserver la couleur UITableViewCell lors du déplacement des lignes UITableView
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSInteger row=[indexPath row];
NSInteger section=[indexPath section];
static NSString *SimpleTableIdentifier1 = @"CellTableIdentifier";
UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier: SimpleTableIdentifier1 ];
if (cell == nil) {
cell=[[[UITableViewCell alloc] initWithFrame:CGRectZero//SimpleTableIdentifier1
reuseIdentifier:nil] autorelease];
}
//------------------------------------------------
if(row==0)
{
//green color
[cell setBackgroundColor:[UIColor colorWithRed:0.10f green:0.95f blue:0.1f alpha:1.0f]];
}
else //white color
[cell setBackgroundColor:[UIColor colorWithRed:0.90f green:0.95f blue:1.0f alpha:1.0f]];
return cell;
}
même si je déplace les lignes, j'espère toujours la première couleur de la ligne est verte, donc je définir des codes comme:
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
[tableview reloadData];
}
mais il rapporte Programme signal reçu: « EXC_BAD_ACCESS ». "
Bienvenue tout commentaire
Merci