Skip to content

Is there a way to have this component only show up for some text fields in a viewcontroller? #24

Open
sogwiz opened this Issue Jan 13, 2013 · 5 comments

3 participants

@sogwiz
sogwiz commented Jan 13, 2013

Hi,

Nice component! Is there a way to invoke the DAKeyboardControl only for certain textfields / input fields and not others that exist in the same view controller? Essentially, I'd like to know how to disable it and then re-enable it on the same view controller.

Thank you!

@danielamitay
Owner

This isn't inherently supported, but:

You can add and remove DAKeyboardControl whenever a different UITextField becomes the first responder. Essentially, make sure you handle the delegate methods for each UITextField:

- (void)textFieldDidBeginEditing:(UITextField *)textField;
- (void)textFieldDidEndEditing:(UITextField *)textField;

When a UITextField that you wish to use DAKeyboardControl on begins editing, add it in the textFieldDidBeginEditing: method. Whenever a UITextField that you did use DAKeyboardControl on ends editing, remove DAKeyboardControl.

I hope this description makes sense. Essentially, only add DAKeyboardControl when the desired UITextField is the first responder.

@sogwiz
sogwiz commented Jan 13, 2013

Thank you for the quick response! So when you mention to "add" and "remove" the DAKeyboardControl, what is the proper way to perform the "remove"? Is there a specific function / code snippet I should use to remove the DAKeyboardControl.

@danielamitay
Owner

- (void)removeKeyboardControl; is the balancing call for both initializing functions:

- (void)addKeyboardPanningWithActionHandler:(DAKeyboardDidMoveBlock)didMoveBlock;
- (void)addKeyboardNonpanningWithActionHandler:(DAKeyboardDidMoveBlock)didMoveBlock;

@sogwiz
sogwiz commented Jan 13, 2013

I must be doing something wrong here. See, in my view controller I have the following:
1. bottom toolbar = custom toolbar that is invoked above keyboard via DAKeyboardControl
2. text views that automagically trigger the DAKeyboardControl thanks to you :)
3. a button for a date chooser that invokes this picker control ( https://github.com/wannabegeek/PickerTableViewCell ). I can't get the DAKeyBoardControl to disappear when opening the Picker and reappear after closing the Picker.

Will let you know my findings if I can figure anything out. Your help so far is kindly appreciated

I'm getting weird issues when calling removeKeyboardControl in my textViewDidEndEditingCall

  • (void)textViewDidEndEditing:(UITextView *)textView { [toolBar removeKeyboardControl]; }

{logs}
2013-01-13 15:51:34.510 liveWants[55895:1a603] exception is Cannot remove an observer for the key path "keyboardActiveView.frame" from because it is not registered as an observer.
{logs}

This leads to other errors down the road when I try to invoke the UIPicker without the keyboardControl:

{logs}
2013-01-13 15:49:12.015 liveWants[55773:1a603] exception is Cannot remove an observer for the key path "keyboardActiveView.frame" from because it is not registered as an observer.
2013-01-13 15:49:13.998 liveWants[55773:1a603] did begin editing
2013-01-13 15:49:19.328 liveWants[55773:1a603] exception is Cannot remove an observer for the key path "keyboardActiveView.frame" from because it is not registered as an observer.
2013-01-13 15:49:20.825 liveWants[55773:1a603] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Cannot update for observer for the key path "keyboardActiveView.frame" from , most likely because the value for the key "keyboardActiveView" has changed without an appropriate KVO notification being sent. Check the KVO-compliance of the UIView class.'
*** First throw call stack:
(0x29e6012 0x245ee7e 0x29e5deb 0x1319d64 0x1318312 0x12cd630 0x1317785 0xee765 0x1385dc9 0x2a400c5 0x299aefa 0x12ba482 0x1a51a67 0x1a4adcc 0x16ec446 0x16df3b6 0x16df554 0xfb07d8 0x25e3014 0x25d37d5 0x298caf5 0x298bf44 0x298be1b 0x44b57e3 0x44b5668 0x16a165c 0x399fd 0x27e5)
libc++abi.dylib: terminate called throwing an exception
{logs}

Any idea of what's going on here?

@kylef
kylef commented Feb 7, 2013

5352d1f should have resolved the previous comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.