点击按钮tableview动态添加一行cell


-(void)addCell:(UIButton *)button{
    NSMutableArray *indexPaths = [[NSMutableArray alloc] init];
    NSInteger row = self.dataSource.count;
    NSIndexPath *indexPath = [NSIndexPath indexPathForRow:row inSection:0];
    [indexPaths addObject: indexPath];
    //必须向tableView的数据源数组中相应的添加一条数据
    FoodDesc *foodDesc = [[FoodDesc alloc] init];
    foodDesc.DEFNAME = @"ios";
    foodDesc.DEFDESC = @"66";
    [self.dataSource addObject:foodDesc];
    [self.tableView beginUpdates];
    [self.tableView insertRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationFade];
    [self.tableView endUpdates];

}

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM