Reputation: 21
I have a NSString (with some HTML entities mixed in) being displayed in an UIWebview. Whenever an entity is displayed in the webview, the surrounding whitespace is stripped.
From source:
"I like Bill & Ted's Excellent Adventure."
As displayed in webview:
"I like Bill&Ted's Excellent Adventure."
Upvotes: 2
Views: 997
Reputation: 11
when you show string on screen first you have to trim it. and then show.
There is a method of NSString
stringByTrimmingCharactersInSet to trim in this we pass a character set. Two class methods of this set is already in documentation but you can also create your own set as your requirement.Use whitespaceCharacterSet
or whitespaceAndNewlineCharacterSet
to remove whitespace around strings.
NSString *stringAfterRemovingWhiteSpace = [stringBeforeRemovingWhiteSpace stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]];
Upvotes: 1