SlackTextViewController
SlackTextViewController copied to clipboard
iOS 11 Inverted Mode Problem
Description
In iOS 11 (beta 5) in inverted mode the action buttons are displayed upside down.
Reproducible in:
SlackTextViewController version: 1.9.5 iOS version(s): iOS 11 beta 5 / Xcode 9 beta 5 Device(s): any
Steps to reproduce:
- Create SLKTextViewController in inverted mode (default)
- Add action buttons to UITableViewCell

I have the same issue
@dzenbot maybe something you could have a look at since you have been so gracious fixing the iOS 11 issue in #624
cheers
It’s in the list of things to fix but I encourage everyone to help out. We’re all devs after all.
My current workaround is using https://github.com/benguild/BGTableViewRowActionWithImage and then adding images instead of text labels like this:
UIImage *buttonImage = [UIImage imageNamed:@"CellButtonTrash"];
if([UIDevice currentDevice].systemVersion.floatValue >= 11) {
buttonImage = [UIImage imageWithCGImage:buttonImage.CGImage
scale:buttonImage.scale
orientation:UIImageOrientationDown];
}
Not that great, but it works.
Are you inverting the entire table view cell btw?
Yes, I'm doing cell.transform = self.tableView.transform in tableview:cellForRowAtIndexPath:. It's funny that the order of the buttons is not inverted (which means the buttons are not rotate) but just the labels on them.
I'm looking for ways to get the default UISwipeActionView(?) looks like there is is a way in iOS 11 tableView:trailingSwipeActionsConfigurationForRowAtIndexPath. See docs.
We also see the same issue, I'll continue the search for a solution.
Here's workaround , until we find better option
if floatVersion >= 11 { for view in tableView.subviews { if view.isKind(of: NSClassFromString("UISwipeActionPullView")! ) == true { for subview in view.subviews { subview.transform = tableView.transform } break } } }
This code has to be called on this function
func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]?
What doesn't make sense is that the tableView is already inverted with a transform, which means its subviews should inherit the transformation.
not sure why but this code seems to fix it
Actually that subview added when you try to swipe on cell
That would explain it. It’s created lazily sincd iOS 11, added to the tableview as subview without inheriting the transformation. Tricky.
I wonder if we should just deprecate the inverted mode altogether. It was a hacky approach to start with, plus the non-inverted mode has gotten pretty good since the latest releases.
@dzenbot is it possible to achieve the inverted effect (cells sticking to the bottom) without using inverted mode?
It is, by making the first cell match the remaining height. That is what we do now on the Slack iOS app, vs inverting the tablview and all its subviews.
@dzenbot nice to know! Might as well migrate to that. Does SlackTextViewController help with the calculations for remaining height?
Nop, you will need to handle it on your end since it fully depends on the table view data source.
@dzenbot If you dont use the inverted flag, how can you load the view with the scroll position starting at the bottom? In iOS 11 you can only set the contentOffset or scroll to the bottom row in viewDidLayoutSubviews, which causes a flicker since the tableview is already loaded. Can't see to find another place to set the contentoffset that works.
Nevermind, I was able to do it as follows:
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
if firstLoad {
messagesCollectionView.scrollToBottom()
}
}
Now I am stuck on how to load content to the top of the collectionview while keeping scroll position. What did you mean by "making the first cell match the remaining height" @dzenbot ?
@alijaza since you're not in inverted mode, your first cell will be up just like normal. if you want to display one cell of type A that's sticking to the bottom, you can make another type of cell B that's actually transparent, place it before cell A in the model and make its height equal to the height of table view minus the height of one cell, so that the empty cell actually fills the space above the cell A. is that correct @dzenbot?
Exactly!
Although there are still known iOS 11 / iPhone X issues, I've pushed 1.9.6 release, which is also available on Cocoapods. At least, we've fixed the most critical issues. Thanks again to all the contributors! 👏
@Luzian Scherrer I have commented out this line cell.transform = self.tableView.transform in tableview:cellForRowAtIndexPath: and just added self.tableView.transform = CGAffineTransformIdentity; and its working for me.
@dKasabwala Interesting, I've tried that with iOS 11.4 and iOS 12.0 (Beta) but I cannot get to UISwipeActionPullView. Does your workaround still work for you and are you sure that you are calling the subview search from editActionsForRowAt?