0

我向你解释我的问题。
Sharekit在我的 iphone 应用程序中使用在 Facebook 上分享网址。
我可以分享我的网址,但在描述部分我什么都没有(只是一个空白字段)。
我想写一些文字。

我在方法 send 中的文件 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];

}

有人知道我该如何写网址的描述吗?

4

2 回答 2

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

于 2011-11-22T03:35:22.380 回答
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”这样的换行符。它对我不起作用......希望它有所帮助。

于 2011-10-19T07:36:42.643 回答