UITableViewで追加する場所
UITableViewで新規にセルを追加した時通常はテーブルの一番上に追加される。 アプリによっては下に追加したい場合もある。 ってなわけで通常であれば下記のような処理だが
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
- (void)insertNewToDo:(id)sender { if (!objects) { objects = [[NSMutableArray alloc] init]; } //objects配列に新規辞書配列todo(sender)をいれる。 [objects insertObject:sender atIndex:0]; NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0]; [self.tableView insertRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic]; [self Save]; } |
indexPathForRowの値をobjects.count-1にすることで下に追加されるようになる。 [crayon-686f37fba304f006738… 続きを読むUITableViewで追加する場所