2013-04-17 106 views
-1

我學到了這個示例代碼,並嘗試在我的應用中實現,但照片無法顯示。使用FacebookComposeViewController,但照片無法顯示

enter link description here

enter image description here

enter image description here

- (IBAction)facebookBtn_down:(id)sender { 
if (osVer >= 6.0) { 
    SLComposeViewController *fbVC = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook]; 
    [fbVC setInitialText:apple_F_MSG]; 
    [fbVC addURL:[NSURL URLWithString:APP_URL]]; 
    [fbVC setCompletionHandler:^(SLComposeViewControllerResult res) { 

     if (res == SLComposeViewControllerResultDone) [self AlertToukou]; 
    }]; 
    [self presentModalViewController:fbVC animated:YES]; 
} else { 
    DEFacebookComposeViewController *fbVC = [[[DEFacebookComposeViewController alloc] init] autorelease]; 
    self.modalPresentationStyle = UIModalPresentationCurrentContext; 
    [fbVC setInitialText:apple_F_MSG]; 
    [fbVC addURL:[NSURL URLWithString:APP_URL]]; 
    [fbVC setCompletionHandler:^(DEFacebookComposeViewControllerResult res) { 
     if (res == DEFacebookComposeViewControllerResultDone) [self AlertToukou]; 
     [self dismissModalViewControllerAnimated:YES]; 
     self.modalPresentationStyle = UIModalPresentationFullScreen; 
    }]; 
    [self presentModalViewController:fbVC animated:YES]; 
} 

}

,請給我一些建議,謝謝!

+0

能否請您發佈您的代碼! –

回答

1

從它說,文檔頁面,

DEFacebookComposeViewController *facebookViewComposer = [[DEFacebookComposeViewController alloc] init]; 
self.modalPresentationStyle = UIModalPresentationCurrentContext; 
[facebookViewComposer setInitialText:@"Look on this"]; 
[facebookViewComposer addImage:[UIImage imageNamed:@"1.jpg"]];//<------Check This 
facebookViewComposer.completionHandler = completionHandler; 
[self presentViewController:facebookViewComposer animated:YES completion:^{ }]; 

您應該使用addImage功能和給予適當UIImage對象比它應該是工作。

+0

當我用這個,不是不可不要求 –

+0

請告訴我的錯誤? –

+0

errorError域= com.facebook。 sdk Code = 5「操作無法完成。 (com.facebook.sdk錯誤5.)「 –

0

我發現這個問題:

我沒有設置鍵 「forKey:@」 源」,不是不能上牆

errorError域= com.facebook.sdk代碼= 5發佈「操作無法完成。 (com.facebook.sdk錯誤5)」

if ([self.images count] > 0) { 
     [d setObject:UIImagePNGRepresentation([self.images lastObject]) forKey:@""]; 
     graphPath = @"me/photos"; 
    }