GithubHelp home page GithubHelp logo

danielamitay / dakeyboardcontrol Goto Github PK

View Code? Open in Web Editor NEW
1.6K 1.6K 214.0 774 KB

DAKeyboardControl adds keyboard awareness and scrolling dismissal (ala iMessages app) to any view with only 1 line of code.

License: Other

Ruby 1.72% Objective-C 98.28%

dakeyboardcontrol's People

Contributors

ahti avatar cool8jay avatar danielamitay avatar davbeck avatar echoz avatar ehopealot avatar hswolff avatar janeenneri avatar juri avatar kyleclegg avatar kylef avatar plu avatar yas375 avatar zman0900 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dakeyboardcontrol's Issues

Reproducible bug in offset tableview example

After dragging the keyboard back down again, any scrolling taking place in the tableview causes the bottom bar to dragged up again but without the keyboard.

Also the keyboard is not visible when its slides in from the bottom, only once the animation completes

[UIView inputKeyboardDidHide] raises NSInternalInconsistencyException

The last line in this method (self.keyboardActiveView = nil;) raises the exception.

- (void)inputKeyboardDidHide:(NSNotification *)notification {
    self.keyboardActiveView.hidden = NO;
    self.keyboardActiveView.userInteractionEnabled = YES;
    self.keyboardActiveView = nil;
}

2013-01-01 22:53:48.152 Palaver[4645:907] *** Terminating app due to uncaught exception     
'NSInternalInconsistencyException', reason: 'Cannot update for observer 
<UIView 0x1d5db6e0> for the key path "keyboardActiveView.frame" from
<UIView 0x1d5db6e0>, 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:
(0x325382a3 0x3a1d297f 0x325381c5 0x32def4cf 0x32dc6287 0x32da06d3 0x11f6ef 0x32489037     0x32d9f599 0x343bedc5 0x34676303 0x34355abb 0x343ca8f7 0x340ffc01 0x3a5e94b7 0x3a5eadcb     0x3250bf3b 0x3247eebd 0x3247ed49 0x360402eb 0x34394309 0x35711 0x34d90)
libc++abi.dylib: terminate called throwing an exception

This is the case when a another view opens the keyboard (such as a UIAlertView).

Crash on -[UIView(DAKeyboardControl) inputKeyboardDidShow]

Not sure how to reproduce, but has been showing up in my crash logs. Here is the section that has problems (line 222):

- (void)inputKeyboardDidShow
{
    // Grab the keyboard view
    self.keyboardActiveView = self.keyboardActiveInput.inputAccessoryView.superview; // This line causes crashes sometimes
    self.keyboardActiveView.hidden = NO;

    // If the active keyboard view could not be found (UITextViews...), try again
    if (!self.keyboardActiveView) {
        // Find the first responder on subviews and look re-assign first responder to it
        [self reAssignFirstResponder];
    }
}

Here are two of them:

Application Specific Information:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UICTFontDescriptor inputAccessoryView]: unrecognized selector sent to instance 0x16eeb850'

Last Exception Backtrace:
0   CoreFoundation                       0x2e522f4b __exceptionPreprocess + 131
1   libobjc.A.dylib                      0x38cff6af objc_exception_throw + 36
2   CoreFoundation                       0x2e5268e7 -[NSObject(NSObject) doesNotRecognizeSelector:] + 200
3   CoreFoundation                       0x2e5251cb ___forwarding___ + 704
4   CoreFoundation                       0x2e4744d8 _CF_forwarding_prep_0 + 22
5   ChatSecure                           0x00201437 -[UIView(DAKeyboardControl) inputKeyboardDidShow] (DAKeyboardControl.m:222)
6   CoreFoundation                       0x2e4e5119 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 10
7   CoreFoundation                       0x2e459257 _CFXNotificationPost + 1716
8   Foundation                           0x2ee3ec2d -[NSNotificationCenter postNotificationName:object:userInfo:] + 74
9   UIKit                                0x30d5ab89 -[UIInputViewTransition postNotificationsForTransitionEnd] + 942
10  UIKit                                0x310d6e6d __53-[UIPeripheralHost(UIKitInternal) executeTransition:]_block_invoke1332 + 370
11  UIKit                                0x30ccd7c9 -[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:] + 282
12  UIKit                                0x30ccd417 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 176
13  UIKit                                0x30ccd333 -[UIViewAnimationState animationDidStop:finished:] + 68
14  QuartzCore                           0x30923729 CA::Layer::run_animation_callbacks(void*) + 230
15  libdispatch.dylib                    0x391e2d07 _dispatch_client_callout + 20
16  libdispatch.dylib                    0x391e978d _dispatch_main_queue_callback_4CF$VARIANT$mp + 266
17  CoreFoundation                       0x2e4ed819 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 6
18  CoreFoundation                       0x2e4ec0ed __CFRunLoopRun + 1298
19  CoreFoundation                       0x2e456c27 CFRunLoopRunSpecific + 520
20  CoreFoundation                       0x2e456a0b CFRunLoopRunInMode + 104
21  GraphicsServices                     0x33137283 GSEventRunModal + 136
22  UIKit                                0x30cfa049 UIApplicationMain + 1134
23  ChatSecure                           0x0000f667 main (main.m:31)
24  libdyld.dylib                        0x39207ab7 start + 0

Here is the second one:

Exception Type:  SIGSEGV
Exception Codes: SEGV_ACCERR at 0x1001c
Crashed Thread:  0

Thread 0 Crashed:
0   libobjc.A.dylib                      0x38cfc0ec objc_retain + 12
1   ChatSecure                           0x00275423 -[UIView(DAKeyboardControl) inputKeyboardDidShow] (DAKeyboardControl.m:222)
2   CoreFoundation                       0x2e4e5119 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 10
3   CoreFoundation                       0x2e459257 _CFXNotificationPost + 1716
4   Foundation                           0x2ee3ec2d -[NSNotificationCenter postNotificationName:object:userInfo:] + 74
5   UIKit                                0x30d5ab89 -[UIInputViewTransition postNotificationsForTransitionEnd] + 942
6   UIKit                                0x310d6e6d __53-[UIPeripheralHost(UIKitInternal) executeTransition:]_block_invoke1332 + 370
7   UIKit                                0x30ccd7c9 -[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:] + 282
8   UIKit                                0x30ccd417 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 176
9   UIKit                                0x30ccd333 -[UIViewAnimationState animationDidStop:finished:] + 68
10  QuartzCore                           0x30923729 CA::Layer::run_animation_callbacks(void*) + 230
11  libdispatch.dylib                    0x391e2d07 _dispatch_client_callout + 20
12  libdispatch.dylib                    0x391e978d _dispatch_main_queue_callback_4CF$VARIANT$mp + 266
13  CoreFoundation                       0x2e4ed819 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 6
14  CoreFoundation                       0x2e4ec0ed __CFRunLoopRun + 1298
15  CoreFoundation                       0x2e456c27 CFRunLoopRunSpecific + 520
16  CoreFoundation                       0x2e456a0b CFRunLoopRunInMode + 104
17  GraphicsServices                     0x33137283 GSEventRunModal + 136
18  UIKit                                0x30cfa049 UIApplicationMain + 1134
19  ChatSecure                           0x00083667 main (main.m:31)
20  libdyld.dylib                        0x39207ab7 start + 0

I'll update the issue when more information is available.

addKeyboardNonpanningWithActionHandler doesn't animate the block

From the readme:

[self.view addKeyboardNonpanningWithActionHandler:^(CGRect keyboardFrameInView) {
    // Move interface objects accordingly
    // Animation block is handled for you
}];

This is no longer the case in master. The "action handler" is now set as the keyboardDidCompleteBlock which is only ever run on completion of the UIView animation. The keyboardDidMoveBlock is nil in this case.

addKeyboardPanningWithActionHandler causing leak

I'm profiling my app with Instruments, and there seems to be a memory leak when using the following code:

__weak UITextView *weakTextView = mainTextView;
        [mainTextView addKeyboardPanningWithActionHandler:^(CGRect rect){
            CGRect convertedRect = [weakTextView convertRect:rect toView:weakTextView.superview];
            CGRect textRect = weakTextView.frame;
            textRect.size.height = convertedRect.origin.y;
            weakTextView.frame = textRect;
        }];

I'm using ARC. The leak is a NSMallockBlock. Instruments is saying the leak is coming from this line:

objc_setAssociatedObject(self,
                             &UIViewKeyboardDidMoveBlock,
                             keyboardDidMoveBlock,
                             OBJC_ASSOCIATION_COPY);

I can't seem to figure out what the problem is, but if I comment out all lines inside the actionHandler block, then the leak doesn't occur. Can you try to replicate this?

Using dakeyboardcontrol on iPad formsheet.

The issue I'm running into is that when the keyboard is dismissed the toolbar goes down and disappears off the screen. Any ideas on how to fix this?

Thanks in advance.

hideKeyboard can cause crash in some cases

We are using a split view controller that has the keyboard on it. If the keyboard is activated and the view with the keyboard is changed (but the keyboard control remains active), when hideKeyboard is called, self.keyboardActiveInput returns a deallocated text edit pointer.

Wrapping the 3 lines in hideKeyboard with:

if (self.keyboardActiveView)
{
...
}

This seems to fix this issue. Not sure if this is the best way to take care of this or if the object that self.keyboardActiveInput returns should be set to nil when "inputKeyboardDidHide" is called or something else.

Thanks for a great drop-in!

Keyboard freeze when I go back and forth to the View Controller that has DAKeyboardControl

Hi, I'm usiing this DAKeyboardControl in my app for chat.
It was good and I was pleased until I found several issue. Especially this issue is very annoying and can't find why.
When I go into Chat page with this control and tap the textview to enter message, and then swipe down, it works fine, and I get out of that page, and then right go back again.
When I do this several times, sometimes just once or twice, then the keyboard freeze when I tap the textview. And it take a while like 10 secs before they keyboard active again.

I've commented all the related code and just used this control and same thing happen.
Hope someone can help me fix this issue.

Many thanks.

MFComposeTextContentView receiving setInputAccessoryView in iOS 5.x

Using DAKeyboardControl together with MFMailComposeViewController (i.e. InApp email) results in a crash on iOS 5.x.

When responderDidBecomeActive gets called in your code, textField receives a MFComposeTextContentView object which does not respond to inputAccessoryView.

The crash report looks as follows:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[MFComposeTextContentView setInputAccessoryView:]: unrecognized selector sent to instance 0x877e370'

Note: This happens when trying to edit the body of the InApp email view controller which is when the keyboard becomes active.

Regards,

Sergio

DAKeyboadHandler responds NO to gestureRecognizer:shouldReceiveTouch: when a UITextView is the first responder

I have a UITextView inside a UITableView. I've replaced the following line in two projects now, figured it's a noteworthy change. .

DAKeyboardControl.m:320 gestureRecognizer:shouldReceiveTouch:

return (![touch.view isFirstResponder] || ([self isKindOfClass:[UITextView class]] && [self isEqual:touch.view]));

replaced with

return (![touch.view isFirstResponder] || ([touch.view isKindOfClass:[UITextView class]]));

when using some 3rdparty input method , the origin.y will be negative

in

    [self.view addKeyboardPanningWithActionHandler:^(CGRect keyboardFrameInView) {

        CGRect toolBarFrame = toolbar.frame;
        toolBarFrame.origin.y = keyboardFrameInView.origin.y - toolBarFrame.size.height;
        toolbar.frame = toolBarFrame;


        CGRect tableViewFrame = tableView.frame;
        tableViewFrame.size.height = toolBarFrame.origin.y;
        tableView.frame = tableViewFrame;


        TLog(@"%@",NSStringFromCGRect(keyboardFrameInView));
    }];

CGRect keyboardFrameInView may be like this : {{0, -64}, {320, 252}}

Problem with tabbar

When inside a tabbar controller, retracting the keyboard makes the toolbar disappear.

autoResize support

To truly mimic the iMessage app, DAKeyboardControl needs to support automatically resizing the scrollview/tableview otherwise when the keyboard is shown you can't scroll to the bottom of the view. I have this functionality implemented already but it breaks with DAKeyboardControl as the view does not return to full height until the keyboard has disappeared (leaving a gap whilst dragging)

latest change to refactor KVC causes app to crash:

2013-01-30 01:53:24.144 athlete-staging[36064:707] *** Terminating app due to uncaught exception 'NSRangeException', reason: 'Cannot remove an observer <UIView 0x6f4990> for the key path "keyboardActiveView.frame" from <UIView 0x6f4990> because it is not registered as an observer

i was not having this trouble until the latest update

AutoLayout Issue

Hey there, love this control. However, having an issue that I think is related to autoLayout but not sure. I have copied the code from the sample:
[self.view addKeyboardPanningWithActionHandler:^(CGRect keyboardFrameInView) {
CGRect toolBarFrame = toolBar.frame;
toolBarFrame.origin.y = keyboardFrameInView.origin.y - toolBarFrame.size.height;
toolBar.frame = toolBarFrame;

    CGRect tableViewFrame = tableView.frame;
    tableViewFrame.size.height = toolBarFrame.origin.y;
    tableView.frame = tableViewFrame;
}];

So I have my toolbar that starts at the bottom of the view, then moves up with the keyboard when it shows, but since adding your control the toolbar now moves 2x as (so up to the top of the keyboard + another keyboard size up). Then when I drag the table down and hide the keyboard, the toolbar is moved below the view as well.

Have you encountered this before? Any suggestions?
I am familiar a bit with auto layout but am not sure if that is the cause of this problem or not.

removeKeyboardControl & addKeyboardPanningWithActionHandler issue

When I add a subview to the view, I will call

[self.view removeKeyboardControl];

to remove the keyboard control, but the text field or text view is not dismiss yet. And I re-add

[self.view addKeyboardPanningWithActionHandler:^(CGRect keyboardFrameInView){}];

when I remove the subview from the view. But the drag down to dismiss keyboard is not working :(


In my case, when I added new subviews to the view, I wanted to removeKeyboardControl and add it back after I remove the subview. May I know is there any solutions on this? Thanks!

Keyboard breaks when selecting a non-editable UITextView

Selecting text within a non-editable text view causes the UI to become unresponsive. Try adding this code to the DAKeyboardControl example project.

UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(0, 50, 320, 50)];
[textView setText:@"Example text to select."];
[textView setEditable:NO];
[self.view addSubview:textView];

In iOS7 self.keyboardActiveInput results in EXC_BAD_ACCESS for a UITextView

I am using a UITextView in one of my App's controllers which doesn't rely on the functionality provided by DAKeyboardControl.

When the view containing the UITextView is presented I force the keyboard to appear right away by [self.textView becomeFirstResponder] in viewWillAppear.

This works fine in iOS5 and iOS6. However, in iOS7 this results in a crash which I traced to:

  • (void)inputKeyboardDidShow, self.keyboardActiveInput results in EXC_BAD_ACCESS

Some debugging shows that keyboardActiveInput has a stale value.

I have two workarounds for this issue:

  1. call becomeFirstResponder in viewDidAppear
  2. the following code in viewWillAppear
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {
    dispatch_async(dispatch_get_main_queue(), ^{
        [self.textView becomeFirstResponder];
    });
}
else {
    [self.textView becomeFirstResponder];
}

Both solutions work with the caveat that the keyboard does not appear right away which is not desirable. This appears to be an Apple issue but I am letting you know in case you have some insight which would cause this problem in iOS7. Note that if I exclude DAKeyboardControl support from my App which I can do through a #define, the problem does not surface at all.

My apologies in advance if this is a duplicate issue or ignorance on my part.

Best regards,

Sergio

Adding the control causes MKMapView/UIScrollView inside a UIScrollView to scroll the parent scrollview.

See this question on stack overflow:

http://stackoverflow.com/questions/12450539/mkmapview-panning-causes-parent-uiscrollview-to-scroll/

When you add a MKMapView (or UIScrollView) to a parent UIScrollView, the control hits the method:

  • (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
    {
    return YES;
    }

even if it the control isn't being used.

To replicate this, add a control to a simple one view window. Then add the following code to the viewDidLoad:

UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height)];
[scrollView setAutoresizingMask:UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth];
// Make the content size large to allow scroll view to move
[scrollView setContentSize:CGSizeMake(1000, 2000)];
[self.view addSubview:scrollView];

double mapHeight = 200;

MKMapView *map = [[MKMapView alloc] initWithFrame:CGRectMake(0, 200, self.view.bounds.size.width, mapHeight)];
[scrollView addSubview:map];

This causes the bug to be reproduced. Contact me and I can send you a sample project which reproduces it.

CocoaPod spec should not include folder DAKeyboardControlExample

When adding DAKeyboardControl to your project via CocoaPod, the folder DAKeyboardControlExample is added to the Pod files.

I suggest it should not.

This is a minor issue, as it did not created any problem in my project.
But in a unit test class, Xcode 4.6.3 showed an error when calling a method on my AppDelegate instance.
This is because it was loading the file AppDelegate.h in Pods/DAKeyboardControl/DAKeyboardControlExample/DAKeyboardControlExample/ before the AppDelegate.h of my project.

iOS7 issue

Tried running my app with DAKeyboardControl on Xcode5 DP6 , think there's a problem with the control in iOS7 alone, works fine with iOS6 and XCode4

Not 4.3+ compatible

The code accesses the panGestureRecognizer of UIScrollView. According to the header, this is available since 5.0.

Tested with 4.3 it breaks in line 53 of DAKeyboardControlTableView. No problems with 5.0 simulator.

Regards,
sunatmidnight

Detect when keyboard have completely show and the user lift up the finger if show up with panning

Hello, i want know if there is a way to detect when the UIKeyboard is completely show, because i want scroll to bottom the UIScrollView when it happens. I have a uitextview connected to the DAKeyboardControl, and i want know detect it in two ways:

  • when with panning appears keyboard and it finish, so it all appear and the user lift the finger up;
  • when the user touch the uitext view and the keyboard show up;

it possible?

reAssignFirstResponder has undesirable side effects with TextField/TextView delegate methods

The fix for issue #9 introduces some problems with TextField and TextView delegate methods. Since it calls
[inputView resignFirstResponder];
[inputView becomeFirstResponder];
the delegate methods textViewShouldBeginEditing:, textViewDidBeginEditing:, textViewDidEndEditing:, etc. are called extra times. This causes a problem for validation or other code that might be in those methods.

Storyboard example

First and foremost....I love this control you've created...it's perfect for a pet project I've started recently. I was wondering if you could possibly create an example for Storyboard. I tried for a bit but struggled to get it working properly.

CocoaPods preserve_paths

Thanks for updating the version on CocoaPods.
Is there any particular consideration that adding the DAKeyboardControlExample to the preserve_paths? Because that would cause projects using DAKeyboard to download the DAKeyboardControlExample.

CocoaPod spec out of date

The cocoapod spec has a hard-coded commit number.
This means that anybody who used CocoaPod to install DAKeyboardControl in their project was stuck with a 5 months-old revision. This includes several tickets, with some of the crash related.

Waiting for an update on cocoapod repo, you can use this in your Podfile:

pod 'DAKeyboardControl', :podspec => 'https://raw.github.com/gcerquant/Specs/61dcb82c10fef0254934a5a010cc7ab5a2c2d0e0/DAKeyboardControl/0.0.1/DAKeyboardControl.podspec'

DAKeyboardControl.m -inputKeyboardDidShow: (lines # 208-212)

I have a view with a UITextField and a UITextView, these are always visible also with the keyboard opened. If i select the UITextField is all ok, i can write in that field. If after i select the UITextView, with these lines of code, you are focusing again on the old UITextField (not on the text view i selected). I think this goes in conflict with the system focus on the right responder so i see the cursor blinking on the UITextView (right) but i'm writing on the UITextField (wrong).
The main problem i think is with the UITextView, this type of responder sends the UIKeyboardDidShowNotification notification before of the UITextViewTextDidBeginEditingNotification notification.

thank you

PS: i like the way you implemented the keyboard panning gesture.

Selector issues

I am developing an iOS6 app and when I loaded a keyboard twice I would get unrecognized selector errors for inputKeyboardWillChangeFrame:

I commented out the method below and things started working.

// For the sake of 4.X compatibility
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(inputKeyboardWillChangeFrame:)
name:@"UIKeyboardWillChangeFrameNotification"
object:nil];

Capturing self strongly in this block is likely to lead a retain cycle

Hello, i have this uitableview:

@property (weak, nonatomic) IBOutlet UITableView *tableView;

then in the viewDidLoad i do this:

[self.view addKeyboardPanningWithActionHandler:^(CGRect keyboardFrameInView)     {
    // Move interface objects accordingly
    // Animation block is handled for you

    CGRect tableViewFrame = _tableView.frame;
    tableViewFrame.size.height = keyboardFrameInView.origin.y;
    _tableView.frame = tableViewFrame;
}];

i doesn't use self, but i however have this warning:

"Capturing self strongly in this block is likely to lead a retain cycle"

so i found this "trick":

__weak typeof(self) weakSelf = self;
[self.view addKeyboardPanningWithActionHandler:^(CGRect keyboardFrameInView) {
    // Move interface objects accordingly
    // Animation block is handled for you

    CGRect tableViewFrame = weakSelf.tableView.frame;
    tableViewFrame.size.height = keyboardFrameInView.origin.y;
    weakSelf.tableView.frame = tableViewFrame;
}];

and i receive no warning, and seems work, but i read in the example project that i have to use this:

[self.view removeKeyboardControl];

but where i have to insert it?

Animating 3 views when keyboard shown

Hey Daniel,

I'm having trouble using the DAKeyboardControl with my views layout

My viewController's view has 3 subviews:

  1. top view is a UIView with frame (0,0,320,54)
  2. middle view is a UITableView with frame (0, 54, 320, screenHeight - 54 - 38)
  3. bottom view s a UITextFiled with frame (0, screenHeight - 38, 320, 38)

I want that when the keyboard is shown, my top view & my tableView will animate up until the top view is completely hidden and the tableView y origin is 0. From this point the keyboard is still animating up so now the tableView height should get smaller until the keyboard animation is finished.
(the bottom UITextFiled should behave like in the example - stay above the keyboard)
When user pan to dismiss the keyboard the views should return to original position.

I know that this is a very specific question, but I hope u could help
Thanks

Splitting the UIKeyboard on iPad is not handled properly

The keyboard panning action handler is not called with the appropriate frame after splitting the iPad keyboard. The updated frames are sent in the UIKeyboardDidChangeFrameNotification, but are ignored by DAKeyboardHandler.

Dismissing the keyboard with tab bar layout makes the input view disappear

Hi Daniel,

First of all this is a great library, thanks for sharing with the community.

I'm having some weird behavior when dismissing the keyboard and expecting the accessory view (input view? not sure what to call this) to be returned to its previous position in the screen. This is an app using a tab bar controller layout, so perhaps this is the root cause of the bug.

I can reproduce this issue on your example project by simply changing this line of code:

self.window.rootViewController = [[UINavigationController alloc] initWithRootViewController:[[ViewController alloc] init]];

To this:

UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:[[ViewController alloc] init]];
UITabBarController *tabBarController = [[UITabBarController alloc] init];
tabBarController.viewControllers = [NSArray arrayWithObject:nav];
self.window.rootViewController = tabBarController;

If you make that modification in your example project, you should be able to see the problem. Click the text field and the keyboard will be presented, the input view will slide with it beautifully, but then when you dismiss the keyboard the input view will disappear (presumably below the tab bar).

Am I missing a really obvious thing here to avoid this problem? Any help here would be appreciated.

--Joao

keyboardAppearance not working with DAKeyboardControl

Hi, I have a problem with keyboard color.

I'm using keyboardAppearance property to change color to transparent. But after integrating
DAKeyboardControl this code stop working.

textField.keyboardAppearance = UIKeyboardAppearanceAlert;

Can something be done, maybe there's some workaround?

Thanks,
Dmitry.

Crash when lot of tap on view

Hi,
I use DAKeyboardControl on a chat view controller and i noticed that when i do a lot of tap on the UItableView above the keyboard ( 5/6 tap ) my app crash.

I saw on Xcode the CPU of my iPhone is 100% used before the crash.

I have a crash on DAKeyboardControl.m ( ie: attached screenshot).

I use the code like this :

     __unsafe_unretained typeof(self) weakSelf = self;
    [self.view addKeyboardPanningWithActionHandler:^(CGRect keyboardFrameInView) {
        CGRect toolBarFrame = weakSelf->toolBar.frame;
        toolBarFrame.origin.y = keyboardFrameInView.origin.y - toolBarFrame.size.height ;
        if(weakSelf->keyboardShowing){
            weakSelf->toolBar.frame = toolBarFrame;
        }
        CGRect tableViewFrame = weakSelf->chatTableView.frame;
        tableViewFrame.size.height = toolBarFrame.origin.y - 68.0f;
        weakSelf->chatTableView.frame = tableViewFrame;
    }];

I would be grateful if you if you can help me.

Thanks, DrewDe

crash

iPad split & undocked keyboards

My app (MUDRammer - a Modern MUD Client for iPhone and iPad) depends on DAKeyboardControl for repositioning its input bar when the keyboard shows and hides. Thanks very much for a great component.

Is there a general solution for iPad split and undocked keyboards? These actions either don't generate the standard UIKeyboardWillShowNotification / UIKeyboardWillHideNotification notifications -- or generate only a subset of them -- and DAKeyboardControl is calling my action handler block with some peculiar keyboard frames:

{{9.86076e-32, -64}, {0, 0}} (Initial call, when first undocked or split)
{{7.08514e-32, -64}, {3.01408e-17, 0}} (After dragging the keyboard around for a while)

This tends to corrupt my app's layout. On the bright side, I am able to recover my layout if the keyboard is re-docked (or un-split) because the rects passed into my action handler are sane again.

MFMessageComposeViewController broken on iOS 5

Merely including DAKeyboardControl in a project breaks MFMessageComposeViewController under iOS 5: when the view appears, the message text input field is not visible. If a list of recipients has also been set via code, then the text field appears initially, but disappears as soon as the user taps the recipient field.

It seems that the "null" input accessory view that DAKeyboardControl sets interacts badly with MFMessageComposeViewController. I've been able to fix the missing input field with the following ugly hack. Not sure if this is the right way though:

- (void)swizzled_addSubview:(UIView *)subview
{
    if (([subview isKindOfClass:[UITextView class]] || [subview isKindOfClass:[UITextField class]]) &&
        strcmp(object_getClassName(subview), "MFRecipientTextField") != 0)
    {

No problems on iOS 6, presumably due to the new remote view controllers.

dak_test_mfmsgview

Panning up and down calculates wrong height

Pan down the keyboard half way and then pan up the keyboard again. This will cause the UITextView height to be wrong.

- (void)viewDidLoad
{
    [super viewDidLoad];

    CGRect frame = self.view.bounds;
    self.textView = [[UITextView alloc] initWithFrame:frame];
    self.textView.keyboardAppearance = UIKeyboardAppearanceDark;
    [self.view addSubview:self.textView];

    __weak typeof(self) weakSelf = self;

    [self.textView addKeyboardPanningWithFrameBasedActionHandler:^(CGRect keyboardFrameInView, BOOL opening, BOOL closing) {
        CGRect textViewFrame = weakSelf.textView.frame;
        textViewFrame.size.height = keyboardFrameInView.origin.y;
        weakSelf.textView.frame = textViewFrame;
    } constraintBasedActionHandler:nil];
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.