PFQueryTableViewController 忽略分页设置
PFQueryTableViewController Ignoring Pagination Setting
我正在更新我的 Parse 应用程序,在将所有内容移至 Heroku 之后,使用开源的 Parse 服务器。我的应用程序有一个部分带有 PFQueryTableViewController。几年来,我禁用了分页功能,因为我们只有大约 50 个项目要在 table 中使用。我今天早上 运行 它,在底部,大约 20 个项目后,它拉出了“加载更多”选项。这是东西......它仍然被禁用。为什么会拉高?
- (id)initWithCoder:(NSCoder *)aDecoder
{
self = [super initWithCoder:aDecoder];
if (self) {
// The className to query on
self.parseClassName = @"FritchDirectory";
// Whether the built-in pull-to-refresh is enabled
self.pullToRefreshEnabled = YES;
// Whether the built-in pagination is enabled
self.paginationEnabled = NO;
// The number of objects to show per page
self.objectsPerPage = 0;
}
return self;
}
- (PFQuery *)queryForTable {
NSLog(@"QUERY");
PFQuery *query = [PFQuery queryWithClassName:@"FritchDirectory"];
// 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 orderByAscending:@"title"];
return query;
}
// Customize the number of sections in the table view.
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
// Customize the number of rows in the table view.
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
object:(PFObject *)object
{
static NSString *CellIdentifier = @"Cell";
DirectoryCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
[tableView registerNib:[UINib nibWithNibName:@"DirectoryCell" bundle:nil] forCellReuseIdentifier:@"Cell"];
cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
}
self.theObject = object;
RSSEntryDirectory *entry = [_allEntries objectAtIndex:indexPath.row];
cell.theImageView.image = [UIImage imageNamed:@"icon@2x.png"];
cell.theImageView.contentMode = UIViewContentModeScaleAspectFit;
PFFile *thumbnail = object[@"Picture"];
if ([thumbnail isEqual:[NSNull null]]) {
}
else {
[thumbnail getDataInBackgroundWithBlock:^(NSData *imageData, NSError *error) {
UIImage *thumbnailImage = [UIImage imageWithData:imageData];
NSLog(@"%@", thumbnail);
cell.theImageView.image = thumbnailImage;
cell.theImageView.clipsToBounds = YES;
NSLog(@"%@", thumbnailImage);
//cell.imageView.contentMode = UIViewContentModeScaleAspectFit;
}];
}
cell.names.text = object[@"title"];
NSLog(@"NAMES%@", object[@"title"]);
CALayer * l = [cell.theImageView layer];
[l setMasksToBounds:YES];
[l setCornerRadius:11];
[l setBorderWidth:2.0];
[l setBorderColor:[[UIColor blackColor] CGColor]];
if( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad )
{
UIFont *cellFont = [UIFont fontWithName:@"ArialRoundedMTBold" size:38];
cell.names.font = cellFont;
UIFont *cellFont2 = [UIFont fontWithName:@"ArialRoundedMTBold" size:24];
cell.detailTextLabel.font = cellFont2;
}
else {
UIFont *cellFont = [UIFont fontWithName:@"ArialRoundedMTBold" size:20];
cell.names.font = cellFont;
UIFont *cellFont2 = [UIFont fontWithName:@"ArialRoundedMTBold" size:12];
cell.detailTextLabel.font = cellFont2;
}
return cell;
}
澄清一下。 PFQueryTableViewController
放在 NavigationViewController
中时无法正常工作。确保它位于您的 TableViewController
、TabViewController
或 ViewController
中。
我正在更新我的 Parse 应用程序,在将所有内容移至 Heroku 之后,使用开源的 Parse 服务器。我的应用程序有一个部分带有 PFQueryTableViewController。几年来,我禁用了分页功能,因为我们只有大约 50 个项目要在 table 中使用。我今天早上 运行 它,在底部,大约 20 个项目后,它拉出了“加载更多”选项。这是东西......它仍然被禁用。为什么会拉高?
- (id)initWithCoder:(NSCoder *)aDecoder
{
self = [super initWithCoder:aDecoder];
if (self) {
// The className to query on
self.parseClassName = @"FritchDirectory";
// Whether the built-in pull-to-refresh is enabled
self.pullToRefreshEnabled = YES;
// Whether the built-in pagination is enabled
self.paginationEnabled = NO;
// The number of objects to show per page
self.objectsPerPage = 0;
}
return self;
}
- (PFQuery *)queryForTable {
NSLog(@"QUERY");
PFQuery *query = [PFQuery queryWithClassName:@"FritchDirectory"];
// 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 orderByAscending:@"title"];
return query;
}
// Customize the number of sections in the table view.
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
// Customize the number of rows in the table view.
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
object:(PFObject *)object
{
static NSString *CellIdentifier = @"Cell";
DirectoryCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
[tableView registerNib:[UINib nibWithNibName:@"DirectoryCell" bundle:nil] forCellReuseIdentifier:@"Cell"];
cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
}
self.theObject = object;
RSSEntryDirectory *entry = [_allEntries objectAtIndex:indexPath.row];
cell.theImageView.image = [UIImage imageNamed:@"icon@2x.png"];
cell.theImageView.contentMode = UIViewContentModeScaleAspectFit;
PFFile *thumbnail = object[@"Picture"];
if ([thumbnail isEqual:[NSNull null]]) {
}
else {
[thumbnail getDataInBackgroundWithBlock:^(NSData *imageData, NSError *error) {
UIImage *thumbnailImage = [UIImage imageWithData:imageData];
NSLog(@"%@", thumbnail);
cell.theImageView.image = thumbnailImage;
cell.theImageView.clipsToBounds = YES;
NSLog(@"%@", thumbnailImage);
//cell.imageView.contentMode = UIViewContentModeScaleAspectFit;
}];
}
cell.names.text = object[@"title"];
NSLog(@"NAMES%@", object[@"title"]);
CALayer * l = [cell.theImageView layer];
[l setMasksToBounds:YES];
[l setCornerRadius:11];
[l setBorderWidth:2.0];
[l setBorderColor:[[UIColor blackColor] CGColor]];
if( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad )
{
UIFont *cellFont = [UIFont fontWithName:@"ArialRoundedMTBold" size:38];
cell.names.font = cellFont;
UIFont *cellFont2 = [UIFont fontWithName:@"ArialRoundedMTBold" size:24];
cell.detailTextLabel.font = cellFont2;
}
else {
UIFont *cellFont = [UIFont fontWithName:@"ArialRoundedMTBold" size:20];
cell.names.font = cellFont;
UIFont *cellFont2 = [UIFont fontWithName:@"ArialRoundedMTBold" size:12];
cell.detailTextLabel.font = cellFont2;
}
return cell;
}
澄清一下。 PFQueryTableViewController
放在 NavigationViewController
中时无法正常工作。确保它位于您的 TableViewController
、TabViewController
或 ViewController
中。