ios - Swift: Become First Responder on UITextField Not Working? -


i've created custom uiviewcontroller 1 uitextfield on storyboard. on viewdidload, set uitextfield becomefirstresponder, nothing happened (no keyboards popped up).

i tried calling resignfirstresponder(), returned false. next tried find first responder through looping subviews using code on @ get current first responder without using private api. turns out none of sub views first responder.

my viewcontroller in storyboard

enter image description here

my code

class bltestviewcontroller: uiviewcontroller, uitextfielddelegate {      @iboutlet var tf: uitextfield      override func viewdidload() {         super.viewdidload()          tf.delegate = self         tf.becomefirstresponder()         // additional setup after loading view.     } } 

as simple gets...why isn't keyboard coming up!!! 1 thing have on auto layout, i'm not sure if affects keyboard popping up.

i tested textfield calling self.tf.becomefirstresponder() indside viewdidload() function , working absolutely fine. you'll need toggle keyboard pressing command + k nflacco pointed out , disable hardware keyboard in simulator as:

  1. ios simulator -> hardware -> keyboard
  2. uncheck "connect hardware keyboard"

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

python - Django-cities exits with "killed" -

python - How to get a widget position inside it's layout in Kivy? -