ios 开发怎样自动选定tableviewcell的第一行
展开全部
-(IBAction)addRows:(id)sender{
NSMutableArray *indexPaths = [[NSMutableArray alloc] init];
for (int i=0; i<3; i++) {
NSString *s = [[NSString alloc] initWithFormat:@”hello %d”,i];
[datas addObject:s];
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:i inSection:0];
[indexPaths addObject: indexPath];
}
[self.tableView beginUpdates];
[self.tableView insertRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewScrollPositionNone];
[self.tableView endUpdates];
NSMutableArray *indexPaths = [[NSMutableArray alloc] init];
for (int i=0; i<3; i++) {
NSString *s = [[NSString alloc] initWithFormat:@”hello %d”,i];
[datas addObject:s];
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:i inSection:0];
[indexPaths addObject: indexPath];
}
[self.tableView beginUpdates];
[self.tableView insertRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewScrollPositionNone];
[self.tableView endUpdates];
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询