PFQueryTableViewController 在推送时有一条线穿过单元格
PFQueryTableViewController has line going through cells when pushed
我的应用程序中有一个 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;
}
只要将它作为根视图就可以呈现:
如果我从另一个角度展示它是这样的:
-(void)myPrayers {
BlogView1 *prayers = [[BlogView1 alloc] init];
[self.navigationController pushViewController:prayers animated:YES];
}
看起来像这样:
看起来 UITableViewCellSeperatorStyle
属性 需要设置为 UITableViewCellSeparatorStyleNone
...
[_table setSeparatorStyle:UITableViewCellSeparatorStyleNone];
或
将 UITableViewCell
的分隔符颜色设置为清除颜色
[_table setSeparatorColor:<#(UIColor *)#>]
我的应用程序中有一个 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;
}
只要将它作为根视图就可以呈现:
如果我从另一个角度展示它是这样的:
-(void)myPrayers {
BlogView1 *prayers = [[BlogView1 alloc] init];
[self.navigationController pushViewController:prayers animated:YES];
}
看起来像这样:
看起来 UITableViewCellSeperatorStyle
属性 需要设置为 UITableViewCellSeparatorStyleNone
...
[_table setSeparatorStyle:UITableViewCellSeparatorStyleNone];
或
将 UITableViewCell
的分隔符颜色设置为清除颜色
[_table setSeparatorColor:<#(UIColor *)#>]