填充TableView Cell的正确方法

时间:2017-01-12 04:27:31

标签: objective-c uitableview tableviewcell

自2009年以来,这是我填充tableView单元格(自定义单元格)的方式:

A=numpy.matrix('1 3;5 6')
print (A.getI())

这是好还是有更好的方法?有些人说我应该更新TableViewcell自定义类中的所有内容。有什么区别吗?

1 个答案:

答案 0 :(得分:1)

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return Array.count;

}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    FilterTableViewCell *cell = (FilterTableViewCell *)[tableView dequeueReusableCellWithIdentifier:@"filter cell"];
        BrandObjectClass *brandObject = [brandsArray objectAtIndex:indexPath.row];

        cell.lblFilterName.text = brandObject.brandName;
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.lblFilterName.font = [UIFont fontWithName:@"Roboto-Medium" size:cell.lblFilterName.font.pointSize];
            cell.imgTick.hidden = NO;


        return cell;
}

当您使用自定义表格视图单元格时,转换也很重要,因为dequeueReusableCellWithIdentifier会返回UITableViewCell的对象。

希望这会有所帮助。

相关问题