Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

iOS 11 Inverted Mode Problem #616

Open
luzianscherrer opened this issue Aug 14, 2017 · 23 comments
Open

iOS 11 Inverted Mode Problem #616

luzianscherrer opened this issue Aug 14, 2017 · 23 comments

Comments

@luzianscherrer
Copy link

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

@abildgaard
Copy link

abildgaard commented Sep 22, 2017

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

@dzenbot
Copy link

dzenbot commented Sep 22, 2017

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

@luzianscherrer
Copy link
Author

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.

@dzenbot
Copy link

dzenbot commented Sep 22, 2017

Are you inverting the entire table view cell btw?

@luzianscherrer
Copy link
Author

luzianscherrer commented Sep 22, 2017

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.

@bogren
Copy link

bogren commented Sep 22, 2017

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.

@dKasabwala
Copy link

dKasabwala commented Sep 22, 2017

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

@dzenbot
Copy link

dzenbot commented Sep 22, 2017

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

@dKasabwala
Copy link

not sure why but this code seems to fix it

@dKasabwala
Copy link

Actually that subview added when you try to swipe on cell

@dzenbot
Copy link

dzenbot commented Sep 22, 2017

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

@dzenbot
Copy link

dzenbot commented Sep 22, 2017

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.

@akaralar
Copy link

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

@dzenbot
Copy link

dzenbot commented Sep 24, 2017

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.

@akaralar
Copy link

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

@dzenbot
Copy link

dzenbot commented Sep 24, 2017

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

@alijaza
Copy link

alijaza commented Sep 26, 2017

@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
Copy link

alijaza commented Sep 26, 2017

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 ?

@akaralar
Copy link

akaralar commented Sep 27, 2017

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

@dzenbot
Copy link

dzenbot commented Sep 27, 2017

Exactly!

@dzenbot
Copy link

dzenbot commented Nov 2, 2017

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

@VikasSingh-NITB
Copy link

VikasSingh-NITB commented Nov 14, 2017

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

@luzianscherrer
Copy link
Author

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants