Get the current first responder without using a private API

前端 未结 28 2534
夕颜
夕颜 2020-11-22 05:03

I submitted my app a little over a week ago and got the dreaded rejection email today. It tells me that my app cannot be accepted because I\'m using a non-public API; specif

28条回答
  •  我在风中等你
    2020-11-22 05:49

    It's not pretty, but the way I resign the firstResponder when I don't know what that the responder is:

    Create an UITextField, either in IB or programmatically. Make it Hidden. Link it up to your code if you made it in IB.

    Then, when you want to dismiss the keyboard, you switch the responder to the invisible text field, and immediately resign it:

        [self.invisibleField becomeFirstResponder];
        [self.invisibleField resignFirstResponder];
    

提交回复
热议问题