I'm a novice and recreational programmer. I am trying to create an app for iOS that populates the text from my UITextFields. I have 3 the actionField, impactField, and result Field. I'd like for each to have their own line, if possible.
I looked at a similar answer, but it was not any help for me. Does anyone have any tutorials or advice?
- (IBAction)backgroundTap: (id)sender {
[self.actionField resignFirstResponder];
[self.impactField resignFirstResponder];
[self.resultField resignFirstResponder];
}
- (IBAction)sendBullet:(id)sender {
NSString *emailTitle = @"Email";
NSString *messageBody = @"Title";
NSArray *toRecipients = [NSArray arrayWithObject:@"email"];
MFMailComposeViewController *mc = [[MFMailComposeViewController alloc] init];
mc.mailComposeDelegate = self;
[mc setSubject:emailTitle];
[mc setMessageBody:messageBody isHTML:NO];
[mc setToRecipients:toRecipients];
[self presentViewController:mc animated:YES completion:NULL];
All you need to do is build a string from the text fields:
NSString *messageBody = [NSString stringWithFormat:@"Action: %@\nImpact: %@\nResult: %@", self.actionField.text, self.impactField.text, self.resultField.text];
Update the format string as needed. What I present here is just one example.
The \n
is a special value in a string that means "newline". This means the string I show will consist of three lines of text.