Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

nickculbertson

macrumors regular
Original poster
Nov 19, 2010
226
0
Nashville, TN
In the following code:

Code:
- (IBAction)email:(id)sender{
	UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil 
													message:@"message" 
												   delegate:self 
										  cancelButtonTitle:@"Thanks! Maybe Later" 
										  otherButtonTitles:@"Email Name", @"Review",nil];

	[alert show];
	[alert release];
}
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
	if (buttonIndex == 2){
//
	}if (buttonIndex == 1){
		MFMailComposeViewController *picker = 
		[[MFMailComposeViewController alloc] init];
		picker.mailComposeDelegate = self;
		[picker setSubject:@"Name"];  
		
		
		NSString *emailBody = @"Hello my name is _______ _______ . What is yours?"; 
		[picker setMessageBody:emailBody isHTML:YES];
		[self presentModalViewController:picker animated:YES];
		[picker release];
		
	}if (buttonIndex == 0){
//		
	}
}

- (void)mailComposeController:(MFMailComposeViewController*)controller
          didFinishWithResult:(MFMailComposeResult)result
                        error:(NSError*)error {
	[self becomeFirstResponder];
	[self dismissModalViewControllerAnimated:YES];
}

is it possible to add the text from 2 UILabels into the blanks here:

Code:
NSString *emailBody = @"Hello my name is _______ _______ . What is yours?";

?

Thanks,
Nick
 

nickculbertson

macrumors regular
Original poster
Nov 19, 2010
226
0
Nashville, TN
Alright, I got it to work with stringWithFormat:

Code:
NSString *emailBody = [NSString stringWithFormat:@"Hello,   %@ %@ %@ %@ .  Goodbye", textview.text, textview2.text, textview3.text, textview4.text];

Is there a way to have the resulting text appear on multiple lines?

Code:
Hello,
   My Name Is     .
Goodbye

Thanks,
Nick
 

nickculbertson

macrumors regular
Original poster
Nov 19, 2010
226
0
Nashville, TN
Yeah, just use \n (the newline specifier) in your format string.

Thanks, you are correct. I had tried using \n but I couldn't get it to work. As it turns out I coded the line break the right way but it just didn't translate properly in the email body. I ran

Code:
NSLog([NSString stringWithFormat:@"Hello, \n    %@ %@ %@ %@ .  \n  Goodbye.", textview.text, textview2.text, textview3.text, textview4.text]);

it starts a new line at \n. however in

Code:
NSString *emailBody = [NSString stringWithFormat:@"Hello, \n    %@ %@ %@ %@ .  \n  Goodbye.", textview.text, textview2.text, textview3.text, textview4.text];

the email text appears on one line.

Oh well, it isn't totally necessary for my project. I just thought I'd add some ascii art.

EDIT:

Ah ha! this line was in the way.

Code:
[picker setMessageBody:emailBody isHTML:YES];

changed it to

Code:
[picker setMessageBody:emailBody isHTML:NO];

Thanks,
Nick
 
Last edited by a moderator:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.