问题
I'm trying to customize a table view to display a feed of youtube videos based on a search query. I found this code http://pastebin.com/vmV2c0HT which displays a feed of a YouTube channel in a tableview, it works fine. However, when modifying the viewDidLoad function to search for a query instead of a user feed, I always end up with a blank table view.
Here is my viewDidLoad function:
- (void)viewDidLoad {
GDataServiceGoogleYouTube *service = [self youTubeService];
NSString *searchString = @"football";
NSString *uploadsID = kGDataYouTubeUserFeedIDUploads;
NSURL *feedURL = [GDataServiceGoogleYouTube youTubeURLForFeedID:nil];
GDataQueryYouTube* query = [GDataQueryYouTube youTubeQueryWithFeedURL:feedURL];
[query setVideoQuery:searchString];
[query setMaxResults:5];
[service fetchFeedWithQuery:query delegate:self didFinishSelector:@selector(entryListFetchTicket:finishedWithFeed:)];
[super viewDidLoad];
}
Any help would be appreciated.
--------------------- SOLUTION ----------------------
The problem was in two parts:
-There was a mistake in the query fetch call, change it to:
[service fetchFeedWithQuery:query delegate:self didFinishSelector:@selector(request:finishedWithFeed:error:)];
the other selector method wasn't implemented
- The service should not follow next links coz then all the feed will be fetched
[_service setServiceShouldFollowNextLinks:NO];
回答1:
What does your cellForRowAtIndexPath
method look like? Maybe the response you get for a search query is in a different format, and so the previous code you had for cellForRowAtIndexPath
no longer applies. You can try doing some NSLog
calls to see what the information looks like if you want.
来源:https://stackoverflow.com/questions/3507967/youtube-uitableview-from-a-search-query-using-gdata