top | item 8363223

SlackTextViewController: A new growing text input for iOS

200 points| bradya | 11 years ago |github.com

34 comments

order
[+] bradya|11 years ago|reply
We tried other popular text input projects for iOS, but none felt right and worked fully for our needs. We ended up spending a big portion of our time maintaining custom versions of other projects.

For that reason, we decided to build our own growing text input from scratch, and we've just released it as open source. We hope you all will find it useful!

[+] liyanchang|11 years ago|reply
Looks really great. Have you thought about submitting to CocoaControls? (https://www.cocoacontrols.com/) It's the second place that I look for iOS components (after a simple Google search, that is).
[+] obeattie|11 years ago|reply
> Inverted mode for displaying cells upside-down (using CATransform) -- a necessary hack for some messaging apps (including ours)

Care to elaborate? Sounds intriguingly crufty.

[+] bradya|11 years ago|reply
UITableView lays out cells from the top. If there aren't enough cells to fill the screen, there will be an empty area in the bottom part of the table view, between the last cell and the bottom of the table view (as you would expect).

Unfortunately, there isn't a standard way to invert a UITableView, and have cells laid out from the bottom.

So, the easiest solution for us was to set the table's transform to CGAffineTransformMake(1, 0, 0, -1, 0, 0) (flip the whole table upside down) and then give the cells the same transform (to cancel out the table view's transform).

A bit hacky, and causes indexPaths to be inverted as well (0,0 is now at the bottom), but worked for us.

Seen a few other people take this approach as well: https://twitter.com/tapbot_paul/status/461161920402563072

[+] kclay|11 years ago|reply
As someone that doesn't do iOS development it boggles my mind that you guys have to build this feature into your apps.
[+] rip747|11 years ago|reply
I'm with you. I don't do iOS development at all, but I will literally sit there and go through the entire code of every iOS control submission to Hacker News just to see how they accomplish what they do. I cannot believe how much code it takes to do something I feel you can accomplish easily in javascript.

Kudos to all the iOS developers out there. I don't know how you guys manage to do it, but I'm sure glad you do and are willing to share your code with the rest of us.

[+] TeeWEE|11 years ago|reply
Indeed, on android this comes out of the box.
[+] fdsary|11 years ago|reply
So I'm making iOS apps sometimes, but have not implemented a chat feature.

Why would I want to use this rather than a UITableView where I append the newest message in the end of the UITableView every time (you'd have to increase it's length +1 for each new message, but hey that may be ok)?

[+] vertex-four|11 years ago|reply
This implements the input box, not the rest of it. Apparently, an automatically (vertically) expanding input box does not exist for iOS in the standard libraries for it.
[+] mentos|11 years ago|reply
Apple developed Swift to make developer's more expressive and efficient yet they do not provide simple controls like this. Can't tell you how many hours I wasted in the chat portion of my app trying to get a simple growing text input to work!
[+] dzenbot|11 years ago|reply
Try this out and let us know what you think. It's been designed in a way where you shouldn't care about the growing text input and trivial features related to it, but to build your tableView/collectionView cells and content.
[+] harshaw|11 years ago|reply
cool. I was just shopping for a new growing text view since HPGrowingTextView seemed like it was not maintained and buggy on IOS 8.

I settled on https://github.com/oseparovic/MessageComposerView.

It's nice, simple, and does the trick. However, I will definitely checkout SlackTExtViewController.

For people not in IOS development: yes this is crazy that it is not built in. But our tool chain is better :)

[+] thrush|11 years ago|reply
Wow. 192 commits. ~1.5 months of work. For a UITextInputField. This pod was made with love.
[+] dzenbot|11 years ago|reply
Atomic commits yo! But yes, it was built with much love and attention to details.
[+] ljosa|11 years ago|reply
If this works well, then it's enormously useful. I spent way too many hours trying to get the existing solutions to work, without success. (In the end, I had to implement the view in HTML and JavaScript!)
[+] cstigler|11 years ago|reply
Will this work for just the input component with a separate table view controller? That'd make it much more useful for non-messaging apps also.
[+] dzenbot|11 years ago|reply
By subclassing SlackTextViewController, you'll get a tableView or collectionView, and a toolbar at the bottom containing the growing text input. That's basically it. You may decide later to override some methods for disabling or enabling more features.