开发者

iPhone - UIView presented with keyboard - works, but with bug

I have a UIViewController that h开发者_C百科as two text fields, inputA and inputB. inputA works like a normal text field, click it and the keyboard shows up and you can type. But inputB triggers another view (think of it as a button). This second view, MyView, has a custom popup view which is animated to appear with the keyboard. MyView's popup is initially with the alpha to 0 and I have set notifications for when the keyboard shows up to have the popup's view alpha to be set to 1.

This works great, but I have a "bug" where when the keyboard is currently showing because the user tapped inputA first, then they tap inputB, it fires the MyView but because the keyboard is already showing the notification isn't sent to change the popup alpha to 1.

So the question: what is the clean way to work around this issue? I want the view to appear along with the keyboard, but if it is already there, it should just be sent.

Is there a way to test if the keyboard is already showing? I want to do this without setting a bool value every time the keyboard is shown/hide in those two views.


try the following

if ([inputA isFirstResponder] || [inputB isFirstResponder]){

//keyboard is displayed

}else{

//keyboard is not displayed

}

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜