我已经阅读了一些关于MFMailViewController的帖子,并想知道我是否可以在我的Iphone应用程序中使用十进制变量的内容来存储一些计算结果到电子邮件的正文中。从我的iPhone应用程序发送。
以下是我在我的应用程序中使用的计算代码,用于计算并将结果显示在屏幕的Text字段中:
GPM1 = [NSDecimalNumber decimalNumberWithString: GPMinput1.text];
GPM2 = [NSDecimalNumber decimalNumberWithString: GPMinput2.text];
Result = [GPM1 decimalNumberByDividingBy:GPM2] ;
GPMresult.text = [numberFormatter stringFromNumber:Result];
我想将“结果”十进制变量的内容显示为电子邮件正文的一部分。例如:您的GPM结果=“结果”。
任何人都有想法吗?
答案 0 :(得分:1)
试试这个
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]
答案 1 :(得分:0)
你必须在iOS 3.0及更高版本上使用MFMailComposeViewController并实现MFMailComposeViewControllerDelegate协议:
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];
}