简体   繁体   中英

Insert a row at position UITableView

I have a table view in which I want to insert a new row at some position. I have done like this but its giving unexpected output. Am I doing anything wrong here.

 NSIndexPath *indexpath =  [NSIndexPath indexPathForRow:position inSection:0];

NSArray *temp_array = [[NSArray alloc] initWithObjects:indexpath, nil];

[self.table insertRowsAtIndexPaths:temp_array withRowAnimation:UITableViewRowAnimationBottom];

Do I need to do anything more than this. This I'm doing in a separate function (insert_at_position:) Any help is appreciated...

Try this

[self.table beginUpdates];
[self.table insertRowsAtIndexPaths:temp_array withRowAnimation:UITableViewRowAnimationBottom];
[self.table endUpdates];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM