BufferStack BufferStack - 1 year ago 145
Objective-C Question

UIActivityViewController not passing new line characters to some activities

I am using the following code to set up UIActivityViewController:

NSArray *activityItems = [NSArray arrayWithObjects:[self textMessageToShare], nil];

UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
[activityViewController setCompletionHandler:^(NSString *activityType, BOOL completed) {
if (completed) {
[self sendFeedbackWithIndexPath:indexPath AndLikeType:100 AndCell:nil];
[self.navigationController presentViewController:activityViewController
// ...

Issue is that when I copy a message or post to facebook or twitter or email or gmail app or to default Messages app, the new line characters that are in
[self textMessageToShare]
are maintained. However, if I share to other activities like WhatsApp or Viber - all the new line characters are removed, and the whole message is sent as one single line.

Whereas, if I share just text through iOS default Notes app, new line characters are maintained when shared to these apps. How would the Notes app be storing the new line characters? I am using
as the new line character.

For my life unable to even find the reason. Can anyone help?

Answer Source

I was able to make it work by converting the newline characters to "<br/>":

_myDataString=  self.textview.text;
_myDataString= [_myDataString  stringByReplacingOccurrencesOfString:@"\n" withString:@"<br/>"];
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download