MFMessageComposeViewController with Whitespace
I'm using MFMessageComposeViewController
for in-app SMS. The problem is that when开发者_Go百科 I have an NSString
with whitespace to assign to body, it will remove all whitespaces. Below code demonstrates the issue. Interesting thing is that it works when I try to copy the same text to clipboard and paste into the sms app.
- (void)sendSMS {
MFMessageComposeViewController *controller = [[MFMessageComposeViewController alloc] init];
if([MFMessageComposeViewController canSendText])
{
[controller setBody:@" aaa aaa"];
controller.recipients = [NSArray arrayWithObjects:nil];
controller.messageComposeDelegate = self;
[self presentModalViewController:controller animated:YES];
}
[controller release];
}
//it becomes "aaa aaa" on the SMS message box when controller shows up.
Does anybody have any idea how to solve this problem?
Thanks in advance!
This seems to still be a problem 5/2012. However you can force the whitespace with  . Not the best option, but it works. The MFMailComposeController will also drop leading whitespace on the body and the same method works.
精彩评论