如何在我的iphone应用程序发送的电子邮件正文中包含十进制变量的内容
我读过一些关于MFMailViewController的帖子,想知道我是否可以将一个十进制变量的内容(我在Iphone应用程序中使用它来存储一些计算结果)包含在从Iphone应用程序发送的电子邮件正文中 以下是我在应用程序中使用的计算代码,用于计算并将结果显示在屏幕的文本字段中:如何在我的iphone应用程序发送的电子邮件正文中包含十进制变量的内容,iphone,cocoa-touch,email,Iphone,Cocoa Touch,Email,我读过一些关于MFMailViewController的帖子,想知道我是否可以将一个十进制变量的内容(我在Iphone应用程序中使用它来存储一些计算结果)包含在从Iphone应用程序发送的电子邮件正文中 以下是我在应用程序中使用的计算代码,用于计算并将结果显示在屏幕的文本字段中: GPM1 = [NSDecimalNumber decimalNumberWithString: GPMinput1.text]; GPM2 = [NSDecimalNumber decimalNumberWithSt
GPM1 = [NSDecimalNumber decimalNumberWithString: GPMinput1.text];
GPM2 = [NSDecimalNumber decimalNumberWithString: GPMinput2.text];
Result = [GPM1 decimalNumberByDividingBy:GPM2] ;
GPMresult.text = [numberFormatter stringFromNumber:Result];
我想将“Result”十进制变量的内容显示为电子邮件正文的一部分。例如:您的GPM result=“result”
任何人都有想法?您必须在iOS 3.0及更高版本上使用MFMailComposeViewController,并实现MFMAILCOMPOSEVIEWCONTROLLEGATE协议:
MFMailComposeViewController* controller = [[MFMailComposeViewController alloc] init];
controller.mailComposeDelegate = self;
[controller setSubject:@"My Subject"];
[controller setMessageBody:@"Hello there." isHTML:NO];
if(controller) {
[self presentModalViewController:controller animated:YES];
}
[controller release];
当用户发送邮件时,您将通过以下方法收到回电:
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error {
if (result == MFMailComposeResultSent) {
NSLog(@"It has been sent.");
}
[self dismissModalViewControllerAnimated:YES];
}
试试这个
float GPM1 = [GPMinput1.text floatValue];
float GPM2 = [GPMinput2.text floatValue]];
float Result = GPM1/GPM2 ;
MFMailComposeViewController *controller = [[MFMailComposeViewController alloc] init];
controller.mailComposeDelegate = self;
NSString *pResult=[NSString stringWithFormat:@"GPM result = %.4f",Result];
[controller setMessageBody: pResult isHTML:NO];
[controller setSubject:@"Subject"];
[self presentModalViewController:controller animated:YES];
[controller release]
@ckurse感谢您的回复,我正在寻找我在问题中提到的具体案例的更具体的答案(包括我在应用程序中使用的某些变量的内容,这些变量将成为要发送的电子邮件正文的一部分,例如,如果变量“Result”我在前面的问题中提到的值为6.12345,那么我希望电子邮件的正文类似于:“GPM结果=6.12345”。知道如何使用MFMailComposecController实现这一点吗?谢谢,但在电子邮件正文中显示“GPM结果=0.000”,而它应该显示“GPM结果=6.1234”其中6.1234是十进制变量“Result”的内容。您的代码中的pResult变量似乎无法读取Result中的十进制值。您可以建议其他工作选项吗?另外,我将Result声明为NSDecimalNumber对象。