How can I make a clickable link in an NSAttributedString?

It’s trivial to make hyperlinks clickable in a UITextView. You just set the “detect links” checkbox on the view in IB, and it detects HTTP links and turns them into hyperlinks. However, that still means that what the user sees is the “raw” link. RTF files and HTML both allow you to set up a … Read more

After upgrading to Xcode 11.2 from Xcode 11.1, app crashes due to _UITextLayoutView

After upgrading to Xcode 11.2 from Xcode 11.1 my app crashes: *** Terminating app due to uncaught exception ‘NSInvalidUnarchiveOperationException’, reason: ‘Could not instantiate class named _UITextLayoutView because no class named _UITextLayoutView was found; the class needs to be defined in source code or linked in from a library (ensure the class is part of the … Read more

Add placeholder text inside UITextView in Swift?

How can I add a placeholder in a UITextView, similar to the one you can set for UITextField, in Swift? 44 Answers 44 Updated for Swift 4 UITextView doesn’t inherently have a placeholder property so you’d have to create and manipulate one programmatically using UITextViewDelegate methods. I recommend using either solution #1 or #2 below … Read more

How to dismiss keyboard for UITextView with return key?

Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted. In IB’s library, the introduction tells us that when the return key is pressed, the keyboard for UITextView will disappear. But actually the return … Read more

Multiple lines of text in UILabel

Is there a way to have multiple lines of text in UILabel like in the UITextView or should I use the second one instead? 26 Answers 26 Set the line break mode to word-wrapping and the number of lines to 0: // Swift textLabel.lineBreakMode = .byWordWrapping textLabel.numberOfLines = 0 // Objective-C textLabel.lineBreakMode = NSLineBreakByWordWrapping; textLabel.numberOfLines … Read more