问题描述:

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:)];
相关阅读:
Top