becomeFirstResponder not working in iOS 8

前端 未结 8 767
不知归路
不知归路 2020-12-09 03:55

I am using UITextField\'s method becomeFirstResponder to show the keyboard. This is working in iOS 7. But in iOS 8 this method doesn\'t show the keyboard.

 U         


        
相关标签:
8条回答
  • 2020-12-09 04:31

    I think you missed the addsubview the txtAddNew to the Mainview

       txtAddNew.tag = 15;
       [self.view addsubview:txtAddNew];  
    
       // Open keyboard
      [txtAddNew becomeFirstResponder];
    
    0 讨论(0)
  • 2020-12-09 04:38

    Swift 3

    Here is the swift 3 version of the accepted answer. For me to get it to work I also had to add a delay.

    txtAddNew.perform(
        #selector(becomeFirstResponder), 
        with: nil, 
        afterDelay: 0.1
    )
    
    0 讨论(0)
提交回复
热议问题