如何从其中包含“&”的 iphone 应用程序发送电子邮件 URL。这是示例网址
http://www.google.co.in/search?hl=en&safe=active&q=facebook&oq=facebook&aq=f&aqi=&aql=&gs_l=mobile-gws-serp.3...0l0l0l1620716l0l0l0l0l0l0l0l0ll0l0.frgbld.&mvs=0
试试这个:在应用程序中的 MFMailComposure iN 电子邮件功能中
-(void)displayComposerSheet
{
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
[picker setSubject:@"My URL!"];
// Set up recipients
NSArray *toRecipients = [NSArray arrayWithObject:@"xyz@abc.com"];
NSString *emailBody = @"http://www.google.co.in/search?hl=en&safe=active&q=facebook&oq=facebook&aq=f&aqi=&aql=&gs_l=mobile-gws-serp.3...0l0l0l1620716l0l0l0l0l0l0l0l0ll0l0.frgbld.&mvs=0";
[picker setMessageBody:emailBody isHTML:NO];
[self presentModalViewController:picker animated:YES];
[picker release];
}
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{
message.hidden = NO;
switch (result)
{
case MFMailComposeResultCancelled:
message.text = @" Message canceled";
break;
case MFMailComposeResultSaved:
message.text = @"Message saved";
break;
case MFMailComposeResultSent:
message.text = @"Message sent";
break;
case MFMailComposeResultFailed:
message.text = @"Message failed";
break;
default:
message.text = @"Message not sent";
break;
}
[self dismissModalViewControllerAnimated:YES];
}
CFStringRef escaped =
CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault,
(CFStringRef)theURL,
NULL,
(CFStringRef)@"!*'();:@&=+$,/?%#[]",
kCFStringEncodingUTF8);
NSString* useit = (NSString*)escaped;
不要忘记释放 CGStringRef