문제

I have a text field and a text view on screen. When my text view is the focused I need to show another view but if the text field is focused not show the view. I am using the UINotification methods to get the keyboard size, but they aren't fired if a text field is focused and the a text view is focused because the whole time the keyboard is shown. Get what I'm saying? So how do I get the keyboard size from somewhere else?

Also: I can't use static values because my app supports different orientations and iPhone and iPad.

도움이 되었습니까?

해결책

Use delegates to get which control is currently focused.UITextViewDelgate method textViewDidBeginEditing: gets called when text view starts editing/focused or become first responder. Similarly UITextFieldDelegate method textFieldDidBeginEditing: can be used for this purpose.

Keyboard size:

See 'rich' answer

Get keyboard size without UIKeyboardWillShowNotification

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top