开发者

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 &nbsp. Not the best option, but it works. The MFMailComposeController will also drop leading whitespace on the body and the same method works.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜