广告图片仅在TableViewController中持续使用Cell

时间:2013-10-05 10:16:34

标签: uitableview parse-platform

我有一个带有来自parse.com的数据的TableView,我根据功能queryfortable放置顺序下降,并由pickerdate选择“Date”。现在最早的日期是最后一个单元格,只有在最后一个单元格中我想添加一个图像...在这种特定情况下,我该怎么办?这对我来说更复杂:(

我只需要在最后一个单元格中插入图像

谢谢Rory

1 个答案:

答案 0 :(得分:1)

如果你正在使用PFQueryTableViewController,那么你应该使用它的自定义子类。

/// MyPFQueryTableViewController.h
@interface MyPFQueryTableViewController : PFQueryTableViewController

self.objects是PFQueryTableViewController类用于每个表行的数据源数组。

您必须检查indexPath.row是否是self.objects数组中的最后一个对象。

MyPFQueryTableViewController.m内覆盖cellForRowAtIndexPath方法:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath object:(PFObject *)object {
    static NSString *CellIdentifier = @"Cell";

    PFTableViewCell *cell = (PFTableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[PFTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }

    // Configure the cell
    // Is this the last displaying cell?
    if( indexPath.row == ([self.objects count]-1) )
    {
        cell.imageView.image = [UIImage imageNamed:@"End_Of_List.jpg"];
        cell.textLabel.text = @"";
    }
    else
    {
        cell.textLabel.text = [object objectForKey:self.textKey];
    }

    return cell;
}
相关问题