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
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:
- ios simulator -> hardware -> keyboard
- uncheck "connect hardware keyboard"
Comments
Post a Comment