为什么单击@" Share"后出现* textToShare?按钮?

时间:2014-12-13 07:23:38

标签: objective-c xcode share ibaction

我想这样,当一个玩家按下@"分享"按钮,他们可以发短信并通过电子邮件发送消息和网址给朋友。我写的代码说了一条消息和网址,但是当我按下分享然后按下消息或发送电子邮件时,它只是一个空文本框。

最后一行似乎也有问题。

它告诉我,没有可见的@interface的' MyScene'声明选择器' presentViewController:activityVC animated:YES completion'

这是我的IBAction

- (IBAction)shareAction:(id)sender {
//  
  NSLog(@"share");
 NSString *textToShare = @"YOOO CHECK IT OUT";
  UIImage *imageToShare = [UIImage imageNamed:@"beck.png"];

  NSURL *urlToShare = [NSURL URLWithString:@"http://www.google.com"];

 NSArray *activityItems = @[textToShare, imageToShare, urlToShare];
 UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
 activityVC.excludedActivityTypes = @[UIActivityTypeMail, UIActivityTypeMessage,                UIActivityTypeAssignToContact, UIActivityTypePrint, UIActivityTypePostToTwitter,    UIActivityTypePostToWeibo];

 UIActivityViewControllerCompletionHandler myBlock = ^(NSString *activityType,BOOL completed) {
NSLog(@"%@", activityType);
if(completed) {
  NSLog(@"completed");
} else
{
  NSLog(@"cancled");
}
[activityVC dismissViewControllerAnimated:YES completion:Nil];
 };
 activityVC.completionHandler = myBlock;
 [self presentViewController:activityVC animated:YES completion:nil];

}

1 个答案:

答案 0 :(得分:1)

您已在 excludedActivityTypes 中提及邮件和消息,那么uiActivityViewController将如何实现
从清除中删除两者并尝试运行。