10

わかりやすいボタン「Safariで開く」を追加したいのですが、どうすれば簡単にできますか。

#pragma mark - Share the link
- (IBAction)activityButtonPressed:(id)sender {


    NSString *textToShare = @"I just shared this from my App";
   // UIImage *imageToShare = [UIImage imageNamed:@"Image.png"];
    NSURL *urlToShare = [NSURL URLWithString:@"http://www.google.com"];
    NSArray *activityItems = [NSArray arrayWithObjects:textToShare, urlToShare,nil];
    UIActivityViewController *activityVC = [[UIActivityViewController alloc]initWithActivityItems:activityItems applicationActivities:Nil];
    //This is an array of excluded activities to appear on the UIActivityViewController
    //activityVC.excludedActivityTypes = @[UIActivityTypeMessage, UIActivityTypeCopyToPasteboard,UIActivityTypeSaveToCameraRoll];
    [self presentViewController:activityVC animated:TRUE completion:nil];


}
4

4 に答える 4

3

このプロジェクトはあなたのためにそれを行います: https://github.com/davbeck/TUSafariActivityで、CocoaPods をサポートしています。

于 2014-07-22T02:29:16.457 に答える
0

UIActivity をサブクラス化し、メソッドを実装してから、クラスを applicationActivities に追加する必要があります

于 2013-12-01T11:54:40.573 に答える
-6
#pragma mark - Share the link
- (IBAction)activityButtonPressed:(id)sender {
    NSURL *urlToShare = [NSURL URLWithString:@"http://www.google.com"];
    [[UIApplication sharedApplication] openURL: urlToShare];
}
于 2013-02-13T10:18:13.870 に答える