2017-07-11 5 views
0

私は2つの異なる表示モードを切り替えるように設定した私のアプリケーションでテーブルビューを持っています。ボタンを押すと、注意が必要なタスクではなく、完了したタスクが表示されるようにテーブルビューが変更されます。タスクの完了または不完全をマークするまで、これは予想どおりに機能します。この後、ユーザーがショーの完全なタスクボタンを押す次回は、それがこのエラーを与えるアプリがクラッシュします:テーブルビュー不明なシャドーエラー

Assertion failure in -[UITableView _addPendingSwipeDeletionShadowUpdateForSection:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit/UIKit-3688.4/UITableView.m:15334

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UITableView internal inconsistency: the _swipedIndexPath cannot be nil when adding the shadow update'

私はエラーが影について何かを言うと、インデックスパスをスワイプ知っているが、私は混乱していませんテーブルビューの影がついているので、何が問題なのかよく分かりません。特に数日前にうまくいきました。

tableView.beginUpdates() 
if showComplete { 
    showComplete = false 
    if completedArray.count != 0 { 
     tableView.deleteSections(NSIndexSet.init(index: 0) as IndexSet, with: .fade) 
    } 
    if taskArray.count != 0 { 
     allComplete() 
    } 
    else { 
     tasksIncomplete() 
     tableView.insertSections(NSIndexSet.init(indexesIn: NSMakeRange(0, taskArray.count)) as IndexSet, with: .fade) 
    }    
} 
else { 
    showComplete = true 
    if taskArray.count != 0 { 
     tableView.deleteSections(NSIndexSet.init(indexesIn: NSMakeRange(0, taskArray.count)) as IndexSet, with: .fade) 
    } 
    if completedArray.count == 0 { 
     allComplete() 
    } 
    else { 
     tasksIncomplete() 
     tableView.insertSections(NSIndexSet.init(index: 0) as IndexSet, with: .fade) 
    }  
} 
tableView.endUpdates() 

機能allComplete()tasksIncomplete()新しいデータが追加されたときに表示したり、データがないときだけのtableViewを隠し、表示さ:完全および不完全データの切り替えのための私のコードはこれです。

self.tableView.beginUpdates() 
self.completedArray.append(thisTask) 
self.taskArray[indexPath.section].remove(at: indexPath.row) 
if self.taskArray[indexPath.section] == [] { 
    self.taskArray.remove(at: indexPath.section) 
    self.dynamicSectionHeaders.remove(at: indexPath.section) 
    self.tableView.deleteSections([indexPath.section], with: .left) 
} 
else { 
    self.tableView.deleteRows(at: [indexPath], with: .automatic) 
} 
self.tableView.endUpdates() 

不完全なタスクをマークするためのコードである:次のようにタスクを完了するために自分のコードである

self.tableView.beginUpdates() 
self.completedArray.remove(at: indexPath.row) 
if self.completedArray.count == 0 { 
    self.tableView.deleteSections([0], with: .left) 
} 
else { 
    self.tableView.deleteRows(at: [indexPath], with: .automatic) 
} 
self.sortIncompleteTaskArray() 
self.tableView.endUpdates() 

taskArrayは、その後のセクションと実際のデータを含む二次元アレイです。 completedArrayはちょうど1次元です。どんな助けでも大歓迎です。私は一生懸命に見てきましたが、このエラーは一度も記録されていないようです。ありがとう。

答えて

0

完全なボタンを押すと、データソース全体を手動で再読み込みすることで問題を解決できました。それは最良の解決策ではないかもしれませんが、うまくいきます。