Enable Return Key in empty UITextView
I need to enable Return Key on UITextView even if UITextView is empty.
Actually, the return key is enabled by default no matter the text view is empty or not. However, if you want to set the return key to disabled by default, you need to set the enablesReturnKeyAutomatically
to YES
. As the Apple Doc said:
The default value for this property is NO. If you set it to YES, the keyboard disables the return key when the text entry area contains no text. As soon as the user enters any text, the return key is automatically enabled.
Disable Return key in keyboard for TextView
You can try this:
func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool {
return text != "\n"
}
Hope it helps!!
Related Topics
How to Save an Array of Objects to Nsuserdefault with Swift
How to Use Writetofile to Save Image in Document Directory
How to Reload Data in a Tableview from a Different Viewcontroller in Swift
Why Nsdateformatter Is Returning Null for a 19/10/2014 in a Brazilian Time Zone
Swift Nsdateformatter Not Working
Uibutton: How to Center an Image and a Text Using Imageedgeinsets and Titleedgeinsets
How to Make App Fully Working Correctly for Autorotation in iOS 6
Change Color of Certain Pixels in a Uiimage
How to Enable_Bitcode in Xcode 7
Error Opening iOS Simulator with iOS 8 Beta Version: "Unable to Boot the iOS Simulator"
Converting Hex String to Nsdata in Swift
Uiactivityviewcontroller Crashing on iOS 8 Ipads
Change Uitableview Height Dynamically
Dealing With Different iOS Device Resolutions in Spritekit
Reloaddata() of Uitableview With Dynamic Cell Heights Causes Jumpy Scrolling
Cgcontextdrawimage Draws Image Upside Down When Passed Uiimage.Cgimage