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

MiniMacLean

macrumors newbie
Original poster
Mar 9, 2008
15
0
I have an application,
It auto rotates,
It has a UITextView,
It has a UINavigationBar,
It has a UIBarButtonItem,

The UIBarButtonItem is linked to a function which is:
Code:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"mailto:email@email.com?subject=Text&body=[B][COLOR="Red"]Text[/COLOR][/B]"]];

However I want the body of the email to be the contents on the UITextView but dont have a clue how to do this,

can i do it with the same function as this now or do i have to use a different function?

______________


also i would like to know how to make the UINavigationBar thin when the application is auto rotated
 

jnic

macrumors 6502a
Oct 24, 2008
567
0
Cambridge
You can access the content of a UITextView via its text property (docs: https://developer.apple.com/iphone/...ce/UITextView_Class/Reference/UITextView.html) i.e.:

Code:
NSString *body = textView.text;

Before you can put it in a mailto to link, you need to escape it, i.e.:

Code:
body = [body stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]

And then you can simply construct the mailto link and insert it into the line of code you provided:

Code:
NSString *mailto = [NSString stringWithFormat:@"mailto:email@email.com?subject=Text&body=%@", body];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:mailto]];
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.