2011-09-14 51 views
0

我向您解釋我的問題。
我在我的iPhone應用程序中使用Sharekit在Facebook上分享網址。
我可以分享我的網址,但在描述部分我什麼也沒有(只是一個空白字段)。
我想寫一些文字。在iPhone上使用sharekit在Facebook上添加說明

我使用中的方法來發送我的文件SHKFacebbok.m驗證碼:

if (item.shareType == SHKShareTypeURL) 
{ 
    self.pendingFacebookAction = SHKFacebookPendingStatus; 
    SHKFBStreamDialog* dialog = [[[SHKFBStreamDialog alloc] init] autorelease]; 
    dialog.delegate = self; 

    dialog.userMessagePrompt = SHKLocalizedString(@"Votre réponse à cette question de merde:"); 
    dialog.attachment = [NSString stringWithFormat: 
         @"{\ 
         \"name\":\"%@\",\ 
         \"href\":\"%@\",\ 
         \"media\":[{\"type\":\"image\",\"src\":\"http://www.samanddon.com/qdm.png\",\"href\":\"http://itunes.apple.com/fr/app/qdm/id453225639?mt=8\"}]\ 
         }", 
         item.title == nil ? SHKEncodeURL(item.URL) : SHKEncode(item.title), 
         SHKEncodeURL(item.URL), 
         SHKEncodeURL(item.URL), 
         SHKEncodeURL(item.URL) 

         ]; 

    dialog.defaultStatus = item.text; 
    dialog.actionLinks = [NSString stringWithFormat:@"[{\"text\":\"Get %@\",\"href\":\"%@\"}]", 
          SHKEncode(SHKMyAppName), 
          SHKEncode(SHKMyAppURL)]; 
    [dialog show]; 

} 

有人知道我怎麼能寫的URL的描述?

回答

0

試試這個:

dialog.attachment = [NSString stringWithFormat: 
           @"{\ 
           \"name\":\"%@\",\ 
           \"href\":\"%@\",\ 
           \"description\":\"%@\",\ 
           \"media\":[{\"type\":\"image\",\"src\":\"http://www.apple.com/images/an_image.png.png\",\"href\":\"http://www.apple.com/\"}]\ 
           }", 

           item.title == nil ? SHKEncodeURL(item.URL) : SHKEncode(item.title), 
           SHKEncodeURL(item.URL), 
           item.text 
           ]; 

注:說明不能有換行像 「\ n」。它不適合我...希望它有幫助。

1

試試這個太:
==在SHKFacebook.m ==

if (item.shareType == SHKShareTypeURL) 
{ 
    self.pendingFacebookAction = SHKFacebookPendingStatus; 

    SHKFBStreamDialog* dialog = [[[SHKFBStreamDialog alloc] init] autorelease]; 
    dialog.delegate = self; 
    dialog.userMessagePrompt = SHKLocalizedString(@"Enter your message:"); 
    dialog.attachment = [NSString stringWithFormat: 
         @"{\ 
         \"name\":\"%@\",\ 
         \"href\":\"%@\",\ 
         \"description\":\"%@\",\ 
         \"media\":[{\"type\":\"image\",\"src\":\"%@\",\"href\":\"%@\"}]\ 
         }", 

         item.title == nil ? SHKEncodeURL(item.URL) : SHKEncode(item.title), 
         SHKEncodeURL(item.URL),item.description, item.picture,SHKEncodeURL(item.URL) 
         ]; 

    dialog.defaultStatus = item.text; 
    dialog.actionLinks = [NSString stringWithFormat:@"[{\"text\":\"Get %@\",\"href\":\"%@\"}]", 
          SHKEncode(SHKMyAppName), 
          SHKEncode(SHKMyAppURL)]; 
    [dialog show]; 

} 


==在SHKItem.h ==
添加新項目:

NSString *picture; 
NSString *description; 


和新房產:

@property (nonatomic, retain) NSString *picture; 
@property (nonatomic, retain) NSString *description; 


==在SHKItem.m ==

+ (SHKItem *)URL:(NSURL *)url 
{ 
    return [self URL:url title:nil description:nil picture:nil]; 
} 

+ (SHKItem *)URL:(NSURL *)url title:(NSString *)title description:(NSString *)description picture:(NSString *)picture 
{ 
    SHKItem *item = [[SHKItem alloc] init]; 
    item.shareType = SHKShareTypeURL; 
    item.URL = url; 
    item.title = title; 
    item.description = description; 
    item.picture = picture; 

    return [item autorelease]; 
} 


==如何使用==

SHKItem *item = [SHKItem URL:yoururl title:yourtitle description:yourdesc picture:yourpicture]; 
SHKActionSheet *actionSheet = [SHKActionSheet actionSheetForItem:item]; 
[actionSheet showFromToolbar:self.navigationController.toolbar]; 

歡呼! :D

相關問題