SlackTextViewController icon indicating copy to clipboard operation
SlackTextViewController copied to clipboard

iOS 11 Inverted Mode Problem

Open luzianscherrer opened this issue 8 years ago • 23 comments

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:

  1. Create SLKTextViewController in inverted mode (default)
  2. Add action buttons to UITableViewCell

screen shot 2017-08-14 at 12 24 53

luzianscherrer avatar Aug 14 '17 10:08 luzianscherrer

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

abildgaard avatar Sep 22 '17 00:09 abildgaard

It’s in the list of things to fix but I encourage everyone to help out. We’re all devs after all.

dzenbot avatar Sep 22 '17 00:09 dzenbot

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.

luzianscherrer avatar Sep 22 '17 08:09 luzianscherrer

Are you inverting the entire table view cell btw?

dzenbot avatar Sep 22 '17 08:09 dzenbot

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.

luzianscherrer avatar Sep 22 '17 08:09 luzianscherrer

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.

bogren avatar Sep 22 '17 09:09 bogren

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]?

dKasabwala avatar Sep 22 '17 17:09 dKasabwala

What doesn't make sense is that the tableView is already inverted with a transform, which means its subviews should inherit the transformation.

dzenbot avatar Sep 22 '17 17:09 dzenbot

not sure why but this code seems to fix it

dKasabwala avatar Sep 22 '17 18:09 dKasabwala

Actually that subview added when you try to swipe on cell

dKasabwala avatar Sep 22 '17 18:09 dKasabwala

That would explain it. It’s created lazily sincd iOS 11, added to the tableview as subview without inheriting the transformation. Tricky.

dzenbot avatar Sep 22 '17 18:09 dzenbot

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 avatar Sep 22 '17 18:09 dzenbot

@dzenbot is it possible to achieve the inverted effect (cells sticking to the bottom) without using inverted mode?

akaralar avatar Sep 23 '17 22:09 akaralar

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 avatar Sep 24 '17 00:09 dzenbot

@dzenbot nice to know! Might as well migrate to that. Does SlackTextViewController help with the calculations for remaining height?

akaralar avatar Sep 24 '17 01:09 akaralar

Nop, you will need to handle it on your end since it fully depends on the table view data source.

dzenbot avatar Sep 24 '17 01:09 dzenbot

@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.

alijaza avatar Sep 26 '17 22:09 alijaza

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 avatar Sep 26 '17 23:09 alijaza

@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?

akaralar avatar Sep 27 '17 00:09 akaralar

Exactly!

dzenbot avatar Sep 27 '17 01:09 dzenbot

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! 👏

dzenbot avatar Nov 02 '17 00:11 dzenbot

@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.

VikasSingh-NITB avatar Nov 14 '17 12:11 VikasSingh-NITB

@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?

luzianscherrer avatar Jul 31 '18 08:07 luzianscherrer