Live data from Hacker News

Implementing a Sticky Input Field in iOS

medium.com

11–19 of 19 posts

Re: Implementing a Sticky Input Field in iOS

#11
post #9

There's no mention in the article that since iOS 7, there's been a "UIScrollViewKeyboardDismissMode", which allows "interactive" dismissal. It isn't perfect, but the last time I investigated, too many solutions out there involved touching private APIs.

I could've more explicit. Interactive dismissal only made possible with UIScrollViewKeyboardDismissModeInteractive introduced since iOS 7. This article described solution for interactive dismissal with `sticky` input field atop the keyboard.

In 2015, most apps shouldn't support anything below iOS 7.

Create a constraint that attaches the input field to the bottom of the scrollview.

One tradeoff is that dismissal doesn't start until your touch enters the real keyboard area. I'll take it, since it's safer than using KVO to observe private APIs.

Re: Implementing a Sticky Input Field in iOS

#12
post #10

This is such a great writeup, thank you for digging into it. Have you tried this out with iOS 9? I know JSQMessagesVC, which does a really solid interactive dismissal, has some problems with that.

Hi, it works in iOS 9. The Pie for iPad screenshot in the post is running in iOS 9.

Re: Implementing a Sticky Input Field in iOS

#13
post #9

Earlier quoted context omitted.

I could've more explicit. Interactive dismissal only made possible with UIScrollViewKeyboardDismissModeInteractive introduced since iOS 7. This article described solution for interactive dismissal with `sticky` input field atop the keyboard.

In 2015, most apps shouldn't support anything below iOS 7. Create a constraint that attaches the input field to the bottom of the scrollview. One tradeoff is that dismissal doesn't start until your touch enters the real keyboard area. I'll take it, since it's safer than using KVO to observe private APIs.

Hi sandofsky, that was our previous implementation (dismissal starts only when user's touch enters the real keyboard area) - it doesn't feel 'right'.

The library is not really using KVO to observe private APIs, bounds/center of UIView is public property.

Re: Implementing a Sticky Input Field in iOS

#14
post #13

Earlier quoted context omitted.

In 2015, most apps shouldn't support anything below iOS 7. Create a constraint that attaches the input field to the bottom of the scrollview. One tradeoff is that dismissal doesn't start until your touch enters the real keyboard area. I'll take it, since it's safer than using KVO to observe private APIs.

Hi sandofsky, that was our previous implementation (dismissal starts only when user's touch enters the real keyboard area) - it doesn't feel 'right'. The library is not really using KVO to observe private APIs, bounds/center of UIView is public property.

You're observing the superview in a hierarchy you don't own. In your code, you have an iOS version check, presumably since the property you're looking for changed between iOS versions.

Re: Implementing a Sticky Input Field in iOS

#15
post #13

Earlier quoted context omitted.

Hi sandofsky, that was our previous implementation (dismissal starts only when user's touch enters the real keyboard area) - it doesn't feel 'right'. The library is not really using KVO to observe private APIs, bounds/center of UIView is public property.

You're observing the superview in a hierarchy you don't own. In your code, you have an iOS version check, presumably since the property you're looking for changed between iOS versions.

yes, that I agree, it may break between iOS versions. i'm all ear to other approach if any

Re: Implementing a Sticky Input Field in iOS

#16
post #15

Earlier quoted context omitted.

You're observing the superview in a hierarchy you don't own. In your code, you have an iOS version check, presumably since the property you're looking for changed between iOS versions.

yes, that I agree, it may break between iOS versions. i'm all ear to other approach if any

You file a ticket with Apple and stick with documented APIs.

Re: Implementing a Sticky Input Field in iOS

#17
post #15

Earlier quoted context omitted.

yes, that I agree, it may break between iOS versions. i'm all ear to other approach if any

You file a ticket with Apple and stick with documented APIs.

will do and hope Apple may do something about that.

until then, will stick to current solution and test ahead of any new iOS release.

Re: Implementing a Sticky Input Field in iOS

#18
post #17

Earlier quoted context omitted.

You file a ticket with Apple and stick with documented APIs.

will do and hope Apple may do something about that. until then, will stick to current solution and test ahead of any new iOS release.

You've decided on the path of higher maintenance, and you've increased the risk of Apple rejection.

Maybe this decision won't bite you, but this mentality will.

Re: Implementing a Sticky Input Field in iOS

#19
post #17

Earlier quoted context omitted.

will do and hope Apple may do something about that. until then, will stick to current solution and test ahead of any new iOS release.

You've decided on the path of higher maintenance, and you've increased the risk of Apple rejection. Maybe this decision won't bite you, but this mentality will.

i keep my options open until I find a better solution.

i'm assuming engineers that build FB messenger, WhatsApp, Twitter etc. could be using similar approach, but I am more than happy to be proven wrong.

Post reply on HN