2016-12-01 1 views
3

Facebook 포드 (세 가지 모두)를 성공적으로 설치했는데 내 앱에 로그인 할 수는 있지만 아무 것도 공유 할 수 없습니다. 있는 viewDidLoad에서Swift 3 & Swift SDK (0.2.0)와 페이스 북 공유

import FacebookLogin 
import FacebookShare 

() :

button.addTarget(self, action: "sharePic", for: .touchUpInside) 

또한 내가 가진 :

코드 (가,하지 진짜 샘플 프로젝트에서의) 매우 간단

func sharePic() { 

    let url = URL(fileURLWithPath: "https://developers.facebook.com")   
    let content = LinkShareContent(url: url, title: "facebook", description: "facebook developers", quote: "fbd", imageURL: nil) 
    try! ShareDialog.show(from: self, content: content) 
} 

이 오류 메시지가 계속 표시됩니다.

fatal error: 'try!' expression unexpectedly raised an error: FacebookShare.ShareError.reserved: file /Library/Caches/com.apple.xbs/Sources/swiftlang/swiftlang-800.0.58.6/src/swift/stdlib/public/core/ErrorType.swift, line 178 

"시도!"에 대한 질문이 없습니다. (나는 나쁜 습관이라는 것을 알고있다.) 그러나 나는 나의 코드에 무엇이 잘못되었는지, 그리고 무엇이 잘못되었는지를 이해하는 방법을 이해하지 못한다.

+0

어떤 해결책이 있습니까? 심지어 같은 문제가 있습니다. –

+0

아니요. 대신 iOS 공유를 사용하고 있습니다. (반짝 반짝 빛나는 것은 아니지만 작동하며 동영상 공유에 제한이 없습니다) – lithium

+0

이 문제를 해결할 수있었습니다. 아래 코드를 –

답변

3
func showShareDialog<C: ContentProtocol>(_ content: C, mode: ShareDialogMode = .automatic) { 
    let dialog = ShareDialog(content: content) 
    dialog.presentingViewController = self 
    dialog.mode = mode 

    do { 
     try dialog.show() 
    } catch (let error) { 
     Toast(text: "Invalid share content. Failed to present share dialog with error \(error)", duration: Delay.short).show() 
    } 
} 

func fbClick() { 
    var content = LinkShareContent(url: URL(string: "http://example.com")!, 
            title: "Title", 
            description: "Description", 
            imageURL: "http://test.com/test.png") 

    showShareDialog(self.content!, mode: .native) 
} 
+1

"예약 됨"오류가 발생했습니다 – Xie

+0

또한 오류 메시지가 예약되었습니다 –

+0

아무에게도 답변이 있습니까? 나는 같은 문제를 겪고있다, 나는 계속 오류를 "예약" –