通过AirDrop共享字符串

时间:2013-12-08 02:49:16

标签: ios iphone ios7 nsstring airdrop

我正在尝试使用AirDrop发送字符串。问题是我不知道如何使用NSURLUITextField发送字符串。如何使用AirDrop从NSString分享UITextField?以下是我的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];

}

0 个答案:

没有答案