TableView
セル間にある程度の間隔を空けたいので、TableView
コードを次のように変更しました。
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return [_boxs count];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return 1;
}
私の問題は、「行の追加\オブジェクト」コードがクラッシュすることです。このコードにどのような変更を加える必要がありますか?
問題のあるコード:
SomeClass *newObject = [[SomeClass alloc]initWithTitle:@".....
[_boxs addObject:newObject];
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:_boxs.count-1 inSection:0];
NSArray *indexPaths = [NSArray arrayWithObject:indexPath];
[self.tableView insertRowsAtIndexPaths:indexPaths withRowAnimation:NO];
[self.tableView selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionMiddle];
[self performSegueWithIdentifier:@"FirstDetailsSegue" sender:self ];
-boxs
NSMutableArrayです。
これは私が得ているエラーです:*キャッチされない例外のためにアプリを終了します'NSInternalInconsistencyException'、理由:'セクション0に行7を挿入しようとしましたが、更新後にセクション0に1行しかありません'