Facebook,iOS SDK [英] Facebook, iOS SDK

查看:150
本文介绍了Facebook,iOS SDK的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在为iOS制作一个Facebook应用程序,将该配置文件Feed放入一个UITableView中。

I am currently making a Facebook application for iOS that pulls the profile feed and puts it in a UITableView.

现在当View Load:

Right Now When the View Loads:

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

和 - (void)请求:(FBRequest *)请求didLoad:(id)result,i有:

and in -(void)request:(FBRequest *)request didLoad:(id)result, i have:

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。

images is a global array, so i can access it in -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath.

所以在 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath, :

so in -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath, i have:

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;

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

So the question I am having a horrible time with is when a user posts a picture or video on the wall, how do i handle that? I would like to display the image/video in the tableview itself. Right Now, it just crashes. Any help would be greatly appreciated.

谢谢,
Virindh Borra

Thanks, Virindh Borra

推荐答案

它什么时候崩溃了?你在代码中放置了任何断点吗?当您将UIImage添加到imagesLocal数组时,您在https://graph.facebook.com/%@/picture中的路径是否包含有效图像?

At what point is it crashing? Did you place any breakpoints in the code? When you add the UIImage to the imagesLocal array, are you the path at "https://graph.facebook.com/%@/picture" contains a valid image?

这篇关于Facebook,iOS SDK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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