Facebook,iOS SDK

我目前正在制作一个Facebook的应用程序的iOS拉动configuration文件饲料,并把它放在一个UITableView。

当视图加载时:

[facebook requestWithGraphPath:@"me/feed" andDelegate:self]; 

和 – (void)请求:(FBRequest *)请求didLoad:(id)结果,我有:

 NSArray *messagesFBData = [result objectForKey:@"data"]; NSMutableArray *friendIds = [NSMutableArray arrayWithCapacity:messagesFBData.count]; NSMutableArray *fromData = [NSMutableArray arrayWithCapacity:messagesFBData.count]; NSMutableArray *imagesLocal = [NSMutableArray arrayWithCapacity:messagesFBData.count]; for (int x = 0; x < messagesFBData.count; x++) { if ([(NSDictionary *)[messagesFBData objectAtIndex:x] objectForKey:@"message"] != nil) { [friendIds addObject:[((NSDictionary*)[messagesFBData objectAtIndex:x]) objectForKey:@"message"]]; NSLog(@"loop Log: %@", [(NSDictionary *)[messagesFBData objectAtIndex:x] objectForKey:@"message"]); [fromData addObject:[((NSDictionary*)[messagesFBData objectAtIndex:x]) objectForKey:@"from"]]; NSLog(@"%@", [((NSDictionary*)[messagesFBData objectAtIndex:x]) objectForKey:@"from"] ); NSDictionary *fromDataDictionary = [fromData objectAtIndex:x]; [imagesLocal addObject:[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://graph.facebook.com/%@/picture", [fromDataDictionary objectForKey:@"id"]]]]]]; NSLog(@"facebook ID: %@", [fromDataDictionary objectForKey:@"id"]); } else { NSLog(@"Nil Called"); } } // don't forget to call loadData for your tableView messages = friendIds; images = imagesLocal; NSLog(@"Equalized"); self.facebookTableView.delegate = self; NSLog(@"Delegate Set"); [facebookTableView reloadData]; 

图像是一个全局数组,所以我可以访问它在 – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath。

所以在 – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath,我有:

 NSLog(@"Cell For Row Called"); UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"messageCell"]; NSString *story = [messages objectAtIndex:indexPath.row]; cell.textLabel.text = story; UIImage *image = [images objectAtIndex:indexPath.row]; cell.imageView.image = image; cell.alpha = 1; return cell; 

所以我有一个可怕的时间问题是,当用户张贴在墙上的图片或video,我该如何处理? 我想在tableview本身显示图像/video。 现在,它只是崩溃。 任何帮助将不胜感激。

谢谢,Virindh Borra

它在什么时候崩溃? 你有没有在代码中放置任何断点? 将UIImage添加到imagesLocal数组中时,“https://graph.facebook.com/%@/picture”中的path是否包含有效的图像&#xFF1F;