Closed mohpor closed 9 years ago
Hi, mophor
Thanks for the suggestion.
It is true that the initial size of the keyboard view is determined by WUEmoticonsKeyboardDefaultSize
. And this decision is based on the following facts:
inputView
property of a UITextView
or UITextField
, the assigned view is automatically resized to fit the screen width (or the input area width). So a keyboard view having a default width of 320 is not a problem. The keyboard view with the default size works on iPad and works even if the device is in landscape mode.alloc/init
.After considering your suggestion, I find this suggestion places a few flaws:
Your suggestion relies on an undocumented behavior.
InputView is contained (a subview) of UIInputSetHostView and we can easily read the actual size of the keyboard from.
The UIInputSetHostView
and its relationship with the keyboard view is not documented. Apple may change the keyboard's internal implementation in a future release of iOS.
-[WUEmoticonsKeyboard setup]
method is executing, the WUEmoticonsKeyboard
is in the middle of its initialization process. It is not added to any view/window yet, so the superview
of the WUEmoticonsKeyboard
is nil and self.superview.bounds.size
is empty.After reconsidering my current implementation, I do find an issue(inconsistency).
When a framework user creates a WUEmoticonsKeyboard
using the designated initializer initWithFrame:
and passes CGRectZero
, he/she will get a WUEmoticonsKeyboard
with the default size(WUEmoticonsKeyboardDefaultSize
). This is inconsistent with the expectation of getting a keyboard view with an empty size.
I fixed this in the latest commit 3fc8a0d3c33dcfd421266d3c41e896b8af4a7d8b
Hi, This is one of the coolest frameworks I've came across on Github and I thank you for sharing it with us.
The bounds of the input view is determined by
WUEmoticonsKeyboardDefaultSize
in your code, a static, predefinedCGSize
. In my experience, it leads to various bugs and view hiccups and we should avoid it. Meanwhile, InputView is contained (a subview) ofUIInputSetHostView
and we can easily read the actual size of the keyboard from.To conclude: In
WUEmoticonsKeyboard.m
at-(void)setup
should be replaced with: