2015-11-05 41 views
0

我有一个由Facebook配置文件获取的图像的URL。我获取这些url并复制到字符串“urlpicture”。在url图片我的网址显示,但是当我传入另一个文件中的字符串类型属性“geturl”。当我进入另一个文件“geturl”时为零。显示Facebook的用户配置文件图像从URL到图像视图

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

  - (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; 

回答

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]; 
       } 
+0

先生,我在我的网址获得价值BT我跳上相同的看法,如果我写你的第二个代码。它在相同的视图导航.. –

+0

HomeViewController是你的另一个视图控制器或相同的视图控制器 –

+0

主视图控制器是另一个视图控制器,我想跳转那些视图控制器,但与退出按钮 –

相关问题