显示从URL到图像视图的Facebook用户个人资料图像

时间:2015-11-05 09:43:51

标签: ios objective-c facebook

我有一个由Facebook个人资料提取的图片网址。我获取这些网址并复制到字符串" urlpicture" 。在url图片中我的网址显示但是当我传入" geturl"这是另一个文件中的字符串类型属性。当我进入另一个文件时,#34; geturl"是零。

这就是为什么我无法在图像视图上显示我的图像。我只是以字符串格式保存图像网址。我应该有一些不同的东西在另一个视图上显示我的图像。

         - (void)  loginButton:(FBSDKLoginButton *)loginButton
            didCompleteWithResult:(FBSDKLoginManagerLoginResult *)result
                            error:(NSError *)error
            {
                FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
                                              initWithGraphPath:@"/me"
                                              parameters:@{ @"fields": @"id,name,picture,email,gender"}
                                              HTTPMethod:@"GET"];
                [request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
                    // Insert your code here
                    NSLog(@"%@",result);
                    if ([result isKindOfClass:[NSDictionary class]])
             {    NSDictionary *pictureData  = [result valueForKey:@"picture"];
                        NSDictionary *redata = [pictureData valueForKey:@"data"];
                                _urlpicture = [redata valueForKey:@"url"];

                    }





                }];


                HomeViewController *pushWithSlot=[self.storyboard instantiateViewControllerWithIdentifier:@"HomeViewController"];

                [self.navigationController setViewControllers:@[pushWithSlot] animated:YES];
                pushWithSlot.geturl=_urlpicture;

1 个答案:

答案 0 :(得分:2)

试试这个,实际上在导航之前传递变量

HomeViewController *pushWithSlot=[self.storyboard instantiateViewControllerWithIdentifier:@"HomeViewController"];

 pushWithSlot.geturl=_urlpicture;
[self.navigationController setViewControllers:@[pushWithSlot] animated:YES];

以上一个不起作用,试试这个原因是URl在你的块里面

{    NSDictionary *pictureData  = [result valueForKey:@"picture"];
                    NSDictionary *redata = [pictureData valueForKey:@"data"];
                            _urlpicture = [redata valueForKey:@"url"];

       // call after URL Fetch
                 HomeViewController *pushWithSlot=[self.storyboard instantiateViewControllerWithIdentifier:@"HomeViewController"];

 pushWithSlot.geturl=_urlpicture;
[self.navigationController setViewControllers:@[pushWithSlot] animated:YES];
                }

然后尝试这个

  {    NSDictionary *pictureData  = [result valueForKey:@"picture"];
                    NSDictionary *redata = [pictureData valueForKey:@"data"];
                            _urlpicture = [redata valueForKey:@"url"];

       // call after URL Fetch
                 HomeViewController *pushWithSlot=[self.storyboard instantiateViewControllerWithIdentifier:@"HomeViewController"];

 pushWithSlot.geturl=pushWithSlot;
[self presentViewController:pushWithSlot 
               animated:YES 
             completion:nil];
                }