UITableViewCell
のラベルを非表示にして、ユーザーがスワイプしてセルを削除するたびにタイトルと重ならないようにしたい。私が使用して、細胞内のラベルを割り当てた削除するためにスワイプしたときにTableViewCellのラベルを非表示にする
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
[self.tableView beginUpdates]; // Avoid NSInternalInconsistencyException
// Delete the project object that was swiped
Project *projectToDelete = [self.fetchedResultsController objectAtIndexPath:indexPath];
NSLog(@"Deleting (%@)", projectToDelete.name);
[self.managedObjectContext deleteObject:projectToDelete];
[self.managedObjectContext save:nil];
// Delete the (now empty) row on the table
[self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationLeft];
[self performFetch];
[self.tableView endUpdates];
}
}
を::
UILabel *projectDate = (UILabel *)[cell viewWithTag:3];
projectDate.text = project.dateStarted;
を、設定だけで試してみましたが、私は削除するスワイプを開始し、処理するために、次のコードを使用してい
projectDate.hidden = YES;
ただし、これは機能しません。
こんにちは、私はUITableViewCellをサブクラス化するという概念を理解していますが、小さな例を提供できますか? – jcrowson
ええ、私の答えを編集します...分。さて、答えは編集されました。 –
いい仕事です(残念ながら2回upvoteすることはできません)が、あなたの例には微調整が必要です。setEditingのスーパーインプリメンテーションを呼び出す必要があります。また、 'animated'パラメータも考慮する必要があります。ラベルの消滅をアニメーション化する。 – jrturton