我正在尝试使用 AirDrop 发送字符串。问题是我不知道如何使用NSURL
从UITextField
. 如何NSString
使用UITextField
AirDrop 进行分享?以下是我的IBAction
代码。但是,发送部分失败。
-(IBAction)sendButton:(id)sender {
NSURL *url = [NSURL URLWithString:self.inputTextField.text];
NSArray *objectsToShare = @[url];
//NSLog(@"you type: %@", self.inputTextField.text);
UIActivityViewController *controller = [[UIActivityViewController alloc] initWithActivityItems:objectsToShare applicationActivities:nil];
// Exclude all activities except AirDrop.
NSArray *excludedActivities = @[UIActivityTypePostToTwitter, UIActivityTypePostToFacebook,
UIActivityTypePostToWeibo,
UIActivityTypeMessage, UIActivityTypeMail,
UIActivityTypePrint, UIActivityTypeCopyToPasteboard,
UIActivityTypeAssignToContact, UIActivityTypeSaveToCameraRoll,
UIActivityTypeAddToReadingList, UIActivityTypePostToFlickr,
UIActivityTypePostToVimeo, UIActivityTypePostToTencentWeibo];
controller.excludedActivityTypes = excludedActivities;
// Present the controller
[self presentViewController:controller animated:YES completion:nil];
//[self.readTextView setText:self.inputTextField.text];
}