Question

I am trying to display photos from the user from Facebook in Objective-C:

Currently, I send an FQL request, retrieve the "src" link and then load this link into a UIWebView.

My question is: is there a better way to display photos from facebook? (UIImageView maybe?)

Just to keep in mind - My goal is to create an app where the thumbnails of each photo is shown, pressing on each photo will make it full screen and users will be able to swipe between enlarged photos (exactly how it is now on the facebook app)

Here is my code to display the first photo (this was just a test)

[FBRequestConnection startWithGraphPath:@"/fql"
                             parameters:queryParam
                             HTTPMethod:@"GET"
                      completionHandler:^(FBRequestConnection *connection,
                                          id result,
                                          NSError *error) {
                          if (error) {
                              NSLog(@"Error: %@", [error localizedDescription]);
                          } else {
                              NSMutableArray *facebookData = [result valueForKey:@"data"];
                              NSDictionary *firstPhotoDictionary = [testArray objectAtIndex:0];
                            //Now i load the link into the UIWebView                                
                              NSString *fullURL = [testpick valueForKey:@"src"];
                              NSURL *url = [NSURL URLWithString:fullURL];
                              NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
                              [_imageWebView loadRequest:requestObj];
                          }
                      }];
Was it helpful?

Solution

I suggest another approach.

1- Create a collection or table view. 2- Make a custom cell with an image on it. 3- When the urls for the photos are on the photos array, use SDWebImage to load them, and most importantly, cache them. 4- Reload the data on your collectionview or tableview, of course the numberOfRowsInSection should be the photos array count. 5- When the user selects an image, use the delegate method, didSelectRowAtIndexPath, and push it to another viewController that has only the image.

I think this would neatly does the job for you! :D

If you need any more clarifications, just ask :) ... Goodluck!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top