我正在使用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];
}
任何想法或我错过或做错了什么?
答案 0 :(得分:1)
尝试更改RootViewController和您正在使用的视图:
[SHK setRootViewController:self.view.window.rootViewController];
[actionSheet showInView:self.view.window.rootViewController.view];
很可能你的视图控制器层次结构有些混乱。