2017-02-28 11 views
1

iOSアプリケーションでは、UITableViewControllerを使用してテーブルビューを表示します。編集モードに切り替えるための組み込みの編集ボタン。いくつかのセルはアクセサリビューを表示する必要があり、これはcell.accessoryType = .detailButtonに設定します。同時に、すべてのセルにcell.editingAccessoryType = .noneが設定されます。また、セルは編集モード中にアクセサリビューの並べ替え、削除、挿入を示します。UITableView:編集モードでのセルアクセサリビューの外観が正しくありません

問題

は問題が編集モードに切り替える際に、アクセサリビューは、いくつかのセルに背後のままで、セルの左上隅に移動していることです。これはランダムに発生するようです。以下

は、各セルを構成するコードである:

private func tableView(_ tableView: UITableView, cellForTextFragment fragment: Fragment, at indexPath: IndexPath) -> UITableViewCell { 
    let cell = tableView.dequeueReusableCell(withIdentifier: basicCellIdentifier, for: indexPath) as! BasicFragmentCell 
    cell.contentTextField.text = fragment.value 
    cell.showsReorderControl = true 

    switch fragment.type { 
    case .phoneNumber, .email: 
     cell.accessoryType = .detailButton 

    default: 
     cell.accessoryType = .none 
    } 
    cell.editingAccessoryType = .none 

    return cell 
} 

完全なソースは、GitHubの上にある:https://github.com/lukevanin/OCRAI

編集モード

Incorrect positioning of accessory view

非編集モード

enter image description here

答えて

0

回避策は、代わりUITableViewControllerを使用する、埋め込みUITableViewで標準UIViewControllerを使用することです。

正しく編集するには、UIViewControllerで編集状態が変更されたときに、編集モードをUITableViewに明示的に設定する必要があります。

override func setEditing(_ editing: Bool, animated: Bool) { 
    super.setEditing(editing, animated: animated) 
    tableView.setEditing(editing, animated: animated) 
} 
関連する問題