3

我正在使用 ShareKit 将对象共享到 Twitter、Facebook 和电子邮件。Twitter 和 Facebook 运行良好,但电子邮件却不行。我真的不知道为什么。

似乎它的工作方式非常随机。

我是这样设置的:

[self.customView.shareButton addTarget:self action:@selector(sharePost:) forControlEvents:UIControlEventTouchUpInside];

- (void)sharePost:(UIButton *)sender
{
    NSURL *url = [NSURL URLWithString:self.currentPost.link];

    // Add image.
    NSString *imageUrlString = [NSString stringWithFormat:[link]];
    NSURL *imageUrl = [NSURL URLWithString:imageUrlString];
    UIImageView *postImage = [[UIImageView alloc] init];
    [postImage setImageWithURL:imageUrl];

    SHKItem *item = [SHKItem image:postImage.image title:[NSString stringWithFormat:@"%@", self.currentPost.title]];
    [item setURL:url];
    [item setMailBody:[NSString stringWithFormat:@"%@ %@", self.currentPost.title, self.currentPost.link]];

    // Get the ShareKit action sheet
    // This works
    SHKActionSheet *actionSheet = [SHKActionSheet actionSheetForItem:item];

    // ShareKit detects top view controller (the one intended to present ShareKit UI) automatically,
    // but sometimes it may not find one. To be safe, set it explicitly.
    [SHK setRootViewController:self];

    // Display the action sheet.
    [actionSheet showInView:self.view];
}

有什么想法或我错过了什么或做错了什么?

4

1 回答 1

1

尝试更改 RootViewController 并查看您正在使用:

[SHK setRootViewController:self.view.window.rootViewController];
[actionSheet showInView:self.view.window.rootViewController.view];

很可能您的视图控制器层次结构有些混乱。

于 2012-08-28T14:18:31.320 回答