uikeyboard

Dismiss keyboard by touching background of UITableView

本小妞迷上赌 提交于 2019-11-26 03:29:03
问题 I have a UITableView with UITextField s as cells. I would like to dismiss the keyboard when the background of the UITableView is touched. I\'m trying to do this by creating a UIButton the size of the UITableView and placing it behind the UITableView . The only problem is the UIButton is catching all the touches even when the touch is on the UITableView. What am I doing wrong? Thanks! 回答1: This is easily done by creating a UITapGestureRecognizer object (by default this will detect a "gesture"

Close iOS Keyboard by touching anywhere using Swift

十年热恋 提交于 2019-11-26 02:25:49
问题 I have been looking all over for this but I can\'t seem to find it. I know how to dismiss the keyboard using Objective-C but I have no idea how to do that using Swift ? Does anyone know? 回答1: override func viewDidLoad() { super.viewDidLoad() //Looks for single or multiple taps. let tap: UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: "dismissKeyboard") //Uncomment the line below if you want the tap not not interfere and cancel other interactions. //tap

How can I make a UITextField move up when the keyboard is present - on starting to edit?

帅比萌擦擦* 提交于 2019-11-25 22:14:37
问题 With the iOS SDK: I have a UIView with UITextField s that bring up a keyboard. I need it to be able to: Allow scrolling of the contents of the UIScrollView to see the other text fields once the keyboard is brought up Automatically \"jump\" (by scrolling up) or shortening I know that I need a UIScrollView . I\'ve tried changing the class of my UIView to a UIScrollView but I\'m still unable to scroll the textboxes up or down. Do I need both a UIView and a UIScrollView ? Does one go inside the