Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/121.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 解析分页加载下一页第二页加载两次_Ios_Parse Platform_Pagination - Fatal编程技术网

Ios 解析分页加载下一页第二页加载两次

Ios 解析分页加载下一页第二页加载两次,ios,parse-platform,pagination,Ios,Parse Platform,Pagination,在我的解析应用程序中,我启用了分页,出于测试目的,将每页对象设置为5。当我运行应用程序时,我会在我的TableView中看到它 一, 二, 三, 四, 五, 加载更多 单击“加载更多”后,整个表如下所示: 一, 二, 三, 四, 五, 六, 七, 八, 九, 十, 六, 七, 八, 九, 十, 在此之后单击“加载更多”将两次添加11-15的集合。发生了什么事 - (id)initWithCoder:(NSCoder *)aDecoder { self = [super initWithC

在我的解析应用程序中,我启用了分页,出于测试目的,将每页对象设置为5。当我运行应用程序时,我会在我的TableView中看到它

一,

二,

三,

四,

五,

加载更多

单击“加载更多”后,整个表如下所示:

一,

二,

三,

四,

五,

六,

七,

八,

九,

十,

六,

七,

八,

九,

十,

在此之后单击“加载更多”将两次添加11-15的集合。发生了什么事

- (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 = 5;

    }
    return self;
}
- (PFQuery *)queryForTable {
    PFQuery *query = [PFQuery queryWithClassName:@"Prayers"];

    // 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;
    BOOL anony = [object[@"Anonymous"] boolValue];


    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;
}
- (PFObject *)objectAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.row == self.objects.count) {
        return nil;
    } else {
        return [super objectAtIndexPath:[NSIndexPath indexPathForRow:indexPath.row inSection:indexPath.section]];
    }
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {

    PFObject *object = [self objectAtIndexPath:indexPath];

    if (object == nil) {
        // Return a fixed height for the extra ("Load more") row
        return 70;
    } else {



   NSLog(@"%lu",  (unsigned long)[self.objects count]);
     PFObject *entry = [self.objects objectAtIndex:indexPath.row];
    NSString *commentString = entry[@"Request"];
    NSString *nameString = @"";
    NSLog(@"%@", commentString);
return [Cell heightForCellWithContentString:(NSString *)commentString] +25 ;
    }
}
#pragma mark -
#pragma mark Table view delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    [super tableView:tableView didSelectRowAtIndexPath:indexPath];

    [tableView deselectRowAtIndexPath:indexPath animated:YES];

    if (indexPath.row == self.objects.count && self.paginationEnabled) {
        // Load More Cell
        NSLog(@"Load More");
        [self loadNextPage];
    }
-(PFQuery *)queryForTable {

...

...

...

//Always trigger a network request.

[tableQuery setCachePolicy:kPFCachePolicyNetworkOnly];

//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) {

   [tableQuery setCachePolicy: kPFCachePolicyCacheThenNetwork];

   }

 ...

 ...

 ...

 return tableQuery;

}