UITableViewで並べ替えコントロールを表示しながらスワイプして削除を有効にする
-
07-07-2019 - |
質問
UITableViewCell
の並べ替えとスワイプによる削除を許可しますが、赤い削除サークルでは許可しません。
- (void)loadView
{
[super loadView];
[table setEditing:YES animated:NO];
}
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete) {
// Perform delete here
}
}
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath
{
// Perform move here
}
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
return UITableViewCellEditingStyleDelete;
}
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
{
return YES;
}
さらに、編集モードを無効にして、運のない-[UITableViewCell setShowsReorderControl:YES]
を呼び出してみました。
(ソース: booleanmagic.com )
解決
カスタムタッチイベントインターセプトを行う必要があると思います。
英語: 指が移動した場合、x距離、セルを水平に横切る、そのセルのみ、削除コントロールを表示します。
左側の円をオフにする方法がわかりませんが、「並べ替え制御を表示」などのプロパティだと思います
所属していません StackOverflow