PFQueryTableViewController在推送时会通过单元格

时间:2015-01-10 02:40:08

标签: ios uitableview parse-platform pfquery

我的应用程序中有一个PFQueryTableViewController。如果它是控制器的根视图,那很好。但是,如果我将它推到另一个视图上,则会有一条奇怪的线穿过每个单元格的顶部。

- (id)initWithCoder:(NSCoder *)aDecoder
{
    self = [super initWithCoder:aDecoder];
    if (self) {

        // The className to query on
        self.parseClassName = @"Prayers";

        // Whether the built-in pull-to-refresh is enabled
        self.pullToRefreshEnabled = YES;

        // Whether the built-in pagination is enabled
        self.paginationEnabled = YES;

        // The number of objects to show per page
        self.objectsPerPage = 20;

    }
    return self;
}
- (PFQuery *)queryForTable {
    PFQuery *query = [PFQuery queryWithClassName:self.parseClassName];

    // If no objects are loaded in memory, we look to the cache first to fill the table
    // and then subsequently do a query against the network.
    if (self.objects.count == 0) {
        query.cachePolicy = kPFCachePolicyCacheThenNetwork;
    }

    [query orderByDescending:@"createdAt"];

    return query;
}

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

    Cell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[Cell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
    }
    self.theObject = object;

    // Configure the cell to show todo item with a priority at the bottom
    cell.profileName.text = object[@"Title"];
    cell.contentLabel.text = object[@"Request"];
    cell.firstName = object[@"FirstName"];
    cell.lastName = object[@"LastName"];
    cell.iostoken = object[@"DeviceID"];
    cell.request = object[@"Title"];
    cell.prayerObject = object;
    PFFile *thumbnail = object[@"ProfilePic"];
    cell.profilePic.image = [UIImage imageNamed:@"AppIcon60x60@2x.png"];
    [cell.commentButton addTarget:self action:@selector(didTapCommentButtonAction:) forControlEvents:UIControlEventTouchUpInside];
    [cell.commentButton setTitle:@"Share" forState:UIControlStateNormal];
    [cell.commentButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [cell.commentButton setTitleColor:[UIColor greenColor] forState:UIControlStateHighlighted];
    [thumbnail getDataInBackgroundWithBlock:^(NSData *imageData, NSError *error) {

        UIImage *thumbnailImage = [UIImage imageWithData:imageData];
        UIImageView *thumbnailImageView = [[UIImageView alloc] initWithImage:thumbnailImage];

        cell.profilePic.image = thumbnailImage;

    }];
    NSString *dates = object[@"dateMade"];
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateFormat:@"MMM_dd_yyyy"];
   NSDate *datefromstring = [formatter dateFromString:dates];
    NSDateFormatter *formatter2 = [[NSDateFormatter alloc] init];
    [formatter2 setDateFormat:@"MMM dd, yyyy"];
    cell.dateLabel.text = [formatter2 stringFromDate:datefromstring];
    UIFont *cellFont = [UIFont fontWithName:@"Verdana-Bold" size:15];
    UIFont *cellFont2 = [UIFont fontWithName:@"Verdana-Bold" size:12];



    return cell;
}

以根视图显示这一点:

enter image description here

如果我从另一个视图中呈现它:

-(void)myPrayers {
    BlogView1 *prayers = [[BlogView1 alloc] init];
    [self.navigationController pushViewController:prayers animated:YES];

}

看起来像这样:

enter image description here

1 个答案:

答案 0 :(得分:1)

看起来UITableViewCellSeperatorStyle属性需要设置为UITableViewCellSeparatorStyleNone ...

    [_table setSeparatorStyle:UITableViewCellSeparatorStyleNone];

OR

UITableViewCell的分隔符颜色设置为清除颜色

    [_table setSeparatorColor:<#(UIColor *)#>]