1

アクションシートを作成し、Facebook 共有オプションを表示したいと考えています。Composeviewcontroller を使用したくありません。私の質問は: ユーザーが IOS6 をインストールしている場合にのみ、Facebook 共有オプションを表示することは可能ですか? コード スニペットは非常に便利です。ソーシャル フレームワークを追加し、いくつかのボタンを含むアクションシートを作成しました。

UIActionSheet *actionsheet = [[UIActionSheet alloc] initWithTitle:@"Empfehlen" delegate:(id)self cancelButtonTitle:@"Abbrechen" destructiveButtonTitle:nil otherButtonTitles:@"メール経由", @"iMessage/SMS経由",@"ツイート" 、なし];

何をすべきか提案や解決策はありますか?

私のアプリは iOS 5 を使用しており、それを維持したいと考えています。

ありがとう。

4

2 に答える 2

4

これは、コメント セクションで OP が行ったフォローアップの質問に対する回答です。

iOS 6 以降では aUIActivityViewControllerを使用できますが、iOS 5 以前ではUIActionSheet.

Class avcClass = NSClassFromString(@"UIActivityViewController");
if (avcClass) {
    NSArray *items = @[ xxx ]; // create one or more activity item objects for this
    UIActivityViewController *avc = [[avcClass alloc] initWithActivityItems:items applicationActivities:nil];
    [self presentViewController:abc animated:YES completion:nil];
} else {
    // create and show an action sheet
}
于 2012-11-02T20:42:31.197 に答える
2

UIActionSheet *actionsheet;

if([SLComposeViewController class] != nil)//some class only available in ios6
{
    actionsheet = [[UIActionSheet alloc] initWithTitle:@"Empfehlen" delegate:(id)self 
cancelButtonTitle:@"Abbrechen" destructiveButtonTitle:nil otherButtonTitles:@"via Mail", @"via iMessage/SMS",@"Tweet", @"Facebook", nil];
}
else
{
    actionsheet = [[UIActionSheet alloc] initWithTitle:@"Empfehlen" delegate:(id)self 
cancelButtonTitle:@"Abbrechen" destructiveButtonTitle:nil otherButtonTitles:@"via Mail", @"via iMessage/SMS",@"Tweet", nil];
}

You're just checking if what you want to share exists and if it does show the option.

于 2012-11-02T19:06:44.200 に答える