I am new to iOS Development and am currently working on an application that receives some kind of JSON data. But some Backend experts thought it would be better for the User if they simply copied the information directly from Word and pasted it into the information system. So I'm sitting here trying to make an interactive link in a UITableView.
I parse the data from the Web and get a line with this format:
Für mehr Informationen klicken sie <a href="http://www.samplelink.com/subpage.php?id=8">here</a>.
I already tried UILabel, but after some research, I use the now often offered UITextView. In the Attributed Inspector, I set it as attribute text and enabled link detection. Now the text is displayed in red and is available for viewing.
Now the problem is that the HTML tags and the correct (German) character set are still missing, and I had no idea how to display it correctly.
The line shown is parsed as follows:
func showHTMLString(unformattedString: String) -> NSAttributedString{ var attrStr = NSAttributedString( data: tmpString.dataUsingEncoding(NSUnicodeStringEncoding, allowLossyConversion: true)!, options: [ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType], documentAttributes: nil, error: nil) return attrStr! }
If I populate a Textview with attrStr?.string , the format displays correctly, but the link also went away.
Any suggestions on the proper formatting of the displayed string?
Thanks in advance AR4G4
ios format swift hyperlink uitextview
a2hur
source share