在MFMailCopose Message中使用字符串变量

时间:2015-07-23 20:48:18

标签: ios objective-c

 - (IBAction)sendButton:(id)sender {

NSString *locationFormatter = [NSString stringWithFormat:@"https://maps.google.com?saddr=Current+Location&daddr=%f,%f", self.locationManager.location.coordinate.latitude, self.locationManager.location.coordinate.longitude];

if ([MFMailComposeViewController canSendMail]){

    MFMailComposeViewController *mailComposer = [[MFMailComposeViewController alloc]init];
    mailComposer.mailComposeDelegate = self;
    [mailComposer setSubject:@"Google Maps Directions"];
    [mailComposer setToRecipients:@[@"castro.michael87@gmail.com"]];
    [mailComposer setMessageBody:@"Google Maps Url:locationFormatter" isHTML:NO];

    // Display Mail Composer
    [self presentViewController:mailComposer animated:YES completion:nil];
}

如何在MessageBody中插入locationFormatter字符串? 我希望这会奏效:

[mailComposer setMessageBody:@"%@",locationFormatter isHTML:NO];

1 个答案:

答案 0 :(得分:0)

尝试:

[mailComposer setMessageBody:[NSString stringWithFormat:@"Google Maps Url:%@", locationFormatter] isHTML:NO];