所以,我在这里描述的问题上取得了一些进展 - https://stackoverflow.com/questions/27348458/svpulltorefresh-infinite-scroll-with-an-rss-feed
尽管如此,我有一个问题。该表最初加载了10个YouTube视频。然后,使用
加载第二个十__weak MasterViewController *weakSelf = self;
[self.tableView addInfiniteScrollingWithActionHandler:^{
NSLog(@"Infinite Scroll");
[weakSelf updateVideoList];
}];
- (void)updateVideoList实际上将10个项添加到加载到表视图中的数组(在addObjectsFromArray将项添加到初始数组之后,最后在tableview上调用reloadData)。这很好用。问题是尝试加载第三个10项不起作用。我添加了NSLog以查看它是否第二次进入该方法,但它没有。
该方法是否有任何理由不能再次工作?
编辑这是updateVideoList,但是我使用日志来确定第二次调用该方法:
- (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];
}
}
答案 0 :(得分:4)
你应该致电
[self.tableView.infiniteScrollingView stopAnimating];
完成重装工作后。