当前位置: 动力学知识库 > 问答 > 编程问答 >

ios - uiactivityviewcontroller from toolbar

问题描述:

I´m trying to use the following code in my app to get the uiactivityviewcontroller, and it works if I set up a round rect button, but not with a UIBarButtonItem? Am I missing something really simple here?

- (IBAction)shareIt:(id)sender {

NSArray *activityItems;

activityItems = @[_textView.text];

UIActivityViewController *activityController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];

[self presentViewController:activityController animated:YES completion:nil];

}

网友答案:

I'm guessing (read: I'm sure) that this is happening because you didn't hook up the action to the barButtonItem correctly in code. If you are making it in code, you can use this:

UIBarButtonItem *bBI = ...; //get it
[bBI setTarget:self];
[bBI setAction:@selector(shareIt:)];
分享给朋友:
您可能感兴趣的文章:
随机阅读: