danielamitay / DAKeyboardControl

DAKeyboardControl adds keyboard awareness and scrolling dismissal (ala iMessages app) to any view with only 1 line of code.
Other
1.58k stars 214 forks source link

Fix iOS9 keyboard target. #98

Open AndresCanella opened 8 years ago

AndresCanella commented 8 years ago

Keyboard target moved, I've targeted the new location. But have not gone in deep to check how all your code works. I've not tested with older versions of iOS, but did add a check to use this fix only for iOS 9+. I apologize if my code is not super clean, I had very little time for this. Cheers.

danielamitay commented 8 years ago

@AndresCanella thanks! Do you happen to know if this works with 3rd party keyboards? Will test later in any case.

AndresCanella commented 8 years ago

@danielamitay Tested and working with Swift Key and regular keyboards on iPhone 6 iOS 9.

Using these methods

- (void)addKeyboardPanningWithFrameBasedActionHandler:(DAKeyboardDidMoveBlock)didMoveFrameBasesBlock
                         constraintBasedActionHandler:(DAKeyboardDidMoveBlock)didMoveConstraintBasesBlock;
- (CGRect)keyboardFrameInView;

And these properties

keyboardFrameInView
keyboardOpened;
keyboardTriggerOffset
AndresCanella commented 8 years ago

@danielamitay Thanks for maintaining this DAKeyboardControl. Good stuff.

rcmstark commented 8 years ago

Yes, it's working. Thanks @AndresCanella .

I like DAKeyboardController, it's better than Apple iOS7 keyboardDismissMode, specially when you have a UIToolBar.

AndresCanella commented 8 years ago

Glad to contribute.

mfarhand commented 8 years ago

yup , it's work as well , but i have problem in Landscape mode , if i want to dismiss my keyboard , every thing in my view going to hidden & textField come from top of my View :| !!!

AndresCanella commented 8 years ago

Good find @mfarhand, I don't use landscape. Was this working properly before? All I did was fetch the target view from where iOS moved it to. It might change on landscape or is now treated differently in some way... If I have some free time I'll take a look.

mfarhand commented 8 years ago

@AndresCanella yup , it was working properly before , but with this code all of my ( bubble ) & ... going to hidden & in touch end event my text field coming from status bar :D !!! can you check it ASAP for me ? another question why @JyaouShingan saied to use UIInputSetContainerView ? i am using this code now & called them like your code , is it ok ?

-(UIView) findInputSetHostView { if([[[UIDevice currentDevice] systemVersion] floatValue] >= 9.0) { for(UIWindow window in [[UIApplication sharedApplication] windows]) if([window isKindOfClass:NSClassFromString(@"UIRemoteKeyboardWindow")]) for(UIView* subView in window.subviews) if([subView isKindOfClass:NSClassFromString(@"UIInputSetHostView")]) for(UIView* subsubView in subView.subviews) if([subsubView isKindOfClass:NSClassFromString(@"UIInputSetHostView")]) return subsubView; } else return self.keyboardActiveInput.inputAccessoryView.superview; return nil; }

you can see the screenshot http://uupload.ir/files/lgg1_img_1049.png

mfarhand commented 8 years ago

@AndresCanella any news ?

AndresCanella commented 8 years ago

@mfarhand I'd love to contribute more but I have my hands full. Have you managed to fix it?

mfarhand commented 8 years ago

@AndresCanella i have handled it only in portrait mode with this way : -(UIView) findInputSetHostView { if([[[UIDevice currentDevice] systemVersion] floatValue] >= 9.0 && [UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortrait ) { for(UIWindow window in [[UIApplication sharedApplication] windows]) if([window isKindOfClass:NSClassFromString(@"UIRemoteKeyboardWindow")]) for(UIView* subView in window.subviews) if([subView isKindOfClass:NSClassFromString(@"UIInputSetHostView")]) for(UIView* subsubView in subView.subviews) if([subsubView isKindOfClass:NSClassFromString(@"UIInputSetHostView")]) return subsubView; } else return self.keyboardActiveInput.inputAccessoryView.superview; return nil; }

AndresCanella commented 8 years ago

@mfarhand You can wait till someone fixes this(who knows when), or you can try to fix it yourself.

You need to figure out what is going on with the views that are being used. For starters you could add NSLogs to all your relative views(frame.x, frame.y. frame.width..). Like the one returned by findInputSetHostView and any other being used by this for something. Eventually you will find what view is sending your view where it should not. From there you can start to think of a solution.

You can also probably find other similar frameworks that have already solved this and check what they did to fix it. Generally you can also find comments of people that have an idea of what's going on. My solution is based on a comment someone did on the original bug report thread. https://github.com/danielamitay/DAKeyboardControl/issues/95#issuecomment-140512365

P.S. Use markdown so your code comments are formatted clearly. You can also embed images.