slackhq / SlackTextViewController

⛔️**DEPRECATED** ⛔️ A drop-in UIViewController subclass with a growing text input view and other useful messaging features
https://slack.com/
MIT License
8.32k stars 1.08k forks source link

Swift Example Scroll to Bottom not working correctly #148

Closed maail closed 9 years ago

maail commented 9 years ago

In the Swift Example, when the text is entered it's not scrolling to the last entered row.

I've tried modifying the slk_scrollToBottomAnimated function in "UIScrollView+SLKAdditions.m" and couldn't get it to work. Might be issue with contentSize.height?

dzenbot commented 9 years ago

I assume you have disabled inverted mode, I am right?

maail commented 9 years ago

self.inverted = false In the Swift example provided yes.

dzenbot commented 9 years ago

This is related to https://github.com/slackhq/SlackTextViewController/pull/144 On inverted = NO, it's a bit more difficult to make the scrolling of the content at the same speed than the keyboard without having a few bugs. Give it a chance at that commit, and let me know. From what I tested, it wasn't solving the issue consistently across all devices, and for some reason, there is a blink when starting scrolling from the bottom of the content view.

maail commented 9 years ago

Tried at that commit. Works a bit better at the start.

But after a row is inserted below the keyboard the last inserted is row is never shown. Have to scroll down to see.

Tried with inverted = YES as well. Same issue. I'm using it with the Swift CollectionView Example. The objective-c examples work though. Might be issue with the custom Cell (SLKMessageViewCell) provided in the example? If so I can debug further.

dzenbot commented 9 years ago

Also related to https://github.com/slackhq/SlackTextViewController/issues/94

maail commented 9 years ago

Porting the programatic Table View example to Swift fixed the issue for me.

The scrolling issue was due to using self.tableView.slk_scrollToBottomAnimated(true) in didPressRightButton function.

Instead used these as in the Programatic Table View Example for didPressRightButton function

var scrollPosition: UITableViewScrollPosition = self.inverted ? UITableViewScrollPosition.Bottom : UITableViewScrollPosition.Top

self.tableView.scrollToRowAtIndexPath(idxPath, atScrollPosition: scrollPosition, animated: true)

self.tableView.reloadRowsAtIndexPaths([idxPath], withRowAnimation: UITableViewRowAnimation.Automatic)

nazywamsiepawel commented 7 years ago

hey @maail, I'm facing a similar issue with the inverted tableview. I've been diggining around but couldn't find a definite answer - has this problem been already solved? Trying your solution now but unfortunately getting a lot of jumping, inaccurate positioning and in some weird behavior with keyboard in general. Do you have any example of it working at hand?