UITableView に新しい行を追加するのに問題があります。私はstackoverflowで同様の質問を読み、それをグーグルで検索しました...助けにはなりませんでした。
UITableView のデータを含む空の NSMutableArray *dataForList があります。画面をクリックした後、新しい行を追加したいと思います。このエラーは次のことを示しています。
*キャッチされない例外 'NSInternalInconsistencyException' が原因でアプリを終了しています。
コード:
NSArray *insertIndexPaths = [NSArray arrayWithObject:
[NSIndexPath indexPathForRow:
[self.dataForList count] // is zero now
inSection:0]];
[self.dataForList addObject:newRow];
// [self.dataForList count] is 1 now
[self.unsignedTableView beginUpdates];
[self.unsignedTableView insertRowsAtIndexPaths:insertIndexPaths withRowAnimation:UITableViewRowAnimationNone];
[self.unsignedTableView endUpdates]; // on this line error ocours
私は何が欠けていますか?
すべての UITableView メソッド
- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *) indexPath {}
- (NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger) section {
return [self.mainController.dataForList count];
}
- (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *) indexPath{
return 38.0f;
}
- (UITableViewCell *) tableView: (UITableView *) tableView
cellForRowAtIndexPath: (NSIndexPath *) indexPath {
// call render method in view, it works fain
return [self.signUpToTestView renderUnsignedCell:tableView cellForRowAtIndexPath:indexPath];
}