2011-09-21 62 views
0

在我的iPhone application.I寫的方法facebookButtonPressed這我輕敲一個鍵調用整合sharekit共享消息的Facebook。 第一次在臉書屏幕上出現其要求在Facebook認證。我給了我的Facebook現有帳戶的用戶名和密碼,並點擊登錄。現在,Facebook身份驗證屏幕消失了。現在我再次點擊按鈕調用方法facebookButtonPressed,然後我收到了消息共享屏幕。 我不想點擊兩次以獲取消息共享屏幕。如果有人已經解決了這個問題,請幫助我。不想兩次在Facebook上使用共享應用程序分享信息?

-(void)facebookButtonPressed{ 
    NSString* body = @"test body"; 
    SHKSharer *fb = [[SHKFacebook alloc] init]; 
    SHKItem *item = [[SHKItem alloc] init]; 
    item.shareType = SHKShareTypeText; 
    item.text = [body length]>140?[body substringToIndex:139]:body; 
    fb.item = item; 
    if(![fb isAuthorized]) 
    [fb authorize]; 
    [fb tryToSend]; 
} 

回答

2

請嘗試下面的代碼,將會有操作表選擇如何分享,您需要選擇Facebook。

NSString* body = @"test body"; 
SHKItem *item = [SHKItem text:body]; 
SHKActionSheet *actionSheet = [SHKActionSheet actionSheetForItem:item]; 
[actionSheet showFromToolbar:self.navigationController.toolbar]; 
1

嘗試把以下內容:

item.shareType = SHKShareTypeText; 
item.text = [body length]>140?[body substringToIndex:139]:body; 
fb.item = item; 

背後[fb tryToSend];

所以,你先檢查FB是否被授權,然後共享。希望能幫助到你。

+0

我試過這個解決方案,但沒有運氣。 – User97693321

+0

所以你需要點擊兩次?或者你有錯誤信息? – Faser