方法无法通过以下方法第二次使用:SVPullToRefresh [英] Method not working on second time through: SVPullToRefresh

查看:77
本文介绍了方法无法通过以下方法第二次使用:SVPullToRefresh的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我在这里描述的问题上取得了一些进展- https ://stackoverflow.com/questions/27348458/svpulltorefresh-infinite-scroll-with-an-rss-feed

So, I've made some progress on my issue described here — https://stackoverflow.com/questions/27348458/svpulltorefresh-infinite-scroll-with-an-rss-feed

尽管如此,我还是有问题.该表最初会加载10个YouTube视频.然后,后十个将使用

Nonetheless, I have a problem. The table loads 10 YouTube videos initially. Then, the second ten will load using

__weak MasterViewController *weakSelf = self;

[self.tableView addInfiniteScrollingWithActionHandler:^{

    NSLog(@"Infinite Scroll");
    [weakSelf updateVideoList];

}];

-(无效)updateVideoList本质上将10个项目添加到加载到表视图的数组中(在addObjectsFromArray将项目添加到初始数组之后,在表视图的最后调用reloadData).这足够好用.问题是尝试加载第三个10个项目不起作用.我添加了NSLog来查看它是否再次进入该方法,但是没有.

-(void) updateVideoList essentially adds 10 items to the array that loads into the table view (reloadData is called on the tableview at the end after addObjectsFromArray adds items to the initial array). This works well enough. The problem is that trying to load a third 10 items does not work. I added the NSLog to see if it even goes into the method a second time, and it doesn't.

该方法是否有第二次不起作用的原因?

Is there any reason for the method to not work a second time?

编辑这是updateVideoList,但是我使用日志来确定该方法甚至没有通过以下方式第二次调用:

Edit Here's updateVideoList, but I used the log to determine that the method isn't even called the second time through:

- (void) updateVideoList {

NSString *baseDomain = @"https://gdata.youtube.com/feeds/api/videos";
NSString *maxresults = @"10";
NSString *startIndex = [NSString stringWithFormat:@"%lu", (unsigned long)videoList.count+1];
NSString *orderBy = @"published";
NSString *author = @"theverge";
NSString *extension = @"v=2&alt=jsonc";
NSString *urlYoutube = [NSString stringWithFormat:@"%@?max-results=%@&start-index=%@&orderby=%@&author=%@&%@",
                        baseDomain,maxresults, startIndex,orderBy,author,extension];

NSDictionary *listOfVideos = [JSONParser listOfVideos:urlYoutube];
int videoListSize = [[[listOfVideos valueForKey:@"data"] valueForKey:@"totalItems"]  intValue];
if (videoListSize>0) {
    NSMutableArray *secondYoutubeList = [[NSMutableArray alloc] init];
    NSArray *arrayVideoList = [[listOfVideos valueForKey:@"data"] valueForKey:@"items"];
    for (NSDictionary *videoDictionary in arrayVideoList) {
        NSString *idVideo = [videoDictionary valueForKey:@"id"];
        NSString *description = [videoDictionary valueForKey:@"description"];
        //NSString *updated = [videoDictionary valueForKey:@"updated"];

        //            NSString *departTimeDate = [videoDictionary valueForKey:@"updated"];
        NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
        [dateFormatter setDateFormat:@"yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'"];
        //NSDate *date = [dateFormatter dateFromString:departTimeDate];

        NSDateComponents *components = [[NSCalendar currentCalendar] components:NSCalendarUnitDay | NSCalendarUnitMonth | NSCalendarUnitYear fromDate:[NSDate date]];
        NSInteger day = [components day];
        NSInteger month = [components month];
        NSInteger year = [components year];

        NSString *updated = [NSString stringWithFormat:@"%ld, %ld, %ld", (long)month,(long)day,(long)year];

        NSString *duration = [videoDictionary valueForKey:@"duration"];

        NSString *title = [videoDictionary valueForKey:@"title"];

        // If we are using wifi, take hqDefault
        NSString *thumbnail = [[videoDictionary valueForKey:@"thumbnail"] valueForKey:@"hqDefault"];
        YoutubeVideo *video = [[YoutubeVideo alloc] initWithId:idVideo withDescription:description withUpdated:updated withDuration:duration withTitle:title withThumbnail:thumbnail];
        [secondYoutubeList addObject:video];

    }
    [videoList addObjectsFromArray:secondYoutubeList];
    [self.tableView reloadData];
}
}

推荐答案

您应该致电

[self.tableView.infiniteScrollingView stopAnimating];

[self.tableView.infiniteScrollingView stopAnimating];

完成重新加载工作.

这篇关于方法无法通过以下方法第二次使用:SVPullToRefresh的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆