MortimerGoro / MGSwipeTableCell

An easy to use UITableViewCell subclass that allows to display swippable buttons with a variety of transitions.
MIT License
6.96k stars 1.07k forks source link

Right Buttons are covered iPhone X when landscape #302

Open VicZhang1 opened 7 years ago

VicZhang1 commented 7 years ago

On iPhone X landscape, the right buttons are covered by status bar.

mrhaxic commented 7 years ago

Screenshot?

pronvit commented 7 years ago

Yes, the behaviour is totally wrong on iPhone X.

MortimerGoro commented 7 years ago

Thanks for the screenshots. I'll take a look.

pronvit commented 7 years ago

Sorry no need for screenshots as it's easy to notice in simulator, and also animation is wrong too.

MortimerGoro commented 7 years ago

Fixed in 1.6.2 ;)

lab0424 commented 7 years ago

it's seems not work after i pull 1.6.4 source code. 2017-11-13 08 29 19

zizicici commented 7 years ago

Hi, @MortimerGoro , this issue still exists in 1.6.4.

MortimerGoro commented 7 years ago

I fixed some calculations and animations (e.g. the behaviour is correct now on the opposite side of the notch, animations are ok).

In order to avoid covering the buttons on the side of the notch, you can do:

-(NSArray*) swipeTableCell:(MGSwipeTableCell*) cell swipeButtonsForDirection:(MGSwipeDirection)direction
             swipeSettings:(MGSwipeSettings*) swipeSettings expansionSettings:(MGSwipeExpansionSettings*) expansionSettings
{
    if (direction == MGSwipeDirectionRightToLeft) {
       swipeSettings.offset = cell.safeAreaInsets.right; // TODO: add availabilty checks to use safeAreaInsets
    } 
(...)
}

I'm thinking on automatically detecting this in the library, but may need some orientation checking to detect the side of the notch. I'll let you know how I include it.

zizicici commented 7 years ago

Hi, Thanks for your reply. I have some issue about your demo, I built that demo and the notch covered the buttons: image

If I add the code swipeSettings.offset = cell.safeAreaInsets.right; The appearance looks a bit strange: image

In iOS 11, Mail.app expand the first or last button width to make appearance looks good. image

image

MortimerGoro commented 7 years ago

In iOS 11, Mail.app expand the first or last button width to make appearance looks good.

Thanks for the info. I still haven't been able to test mail on iPhone X to see how they solved it (Are you running it on the simulator?)

I'll set that solution as the default behaviour. I'll let you know when the update is ready.

zizicici commented 7 years ago

First, I capture the screen shot by using an iPhone X, and drag that shot to the iOS Simulator, then I enable the "Show Device Bezels" in the iOS Simulator, finally I use shift + command + 4 to capture the last image in macOS.

It's my honor to help you, if you need images of other cases, please tell me free.

MortimerGoro commented 7 years ago

1.6.5 published!

By default it mimics the mail app and expands the first or last button width to make appearance look good with the notch.

This behavious can be enabled or disabled on each swipe side by setting expandLastButtonBySafeAreaInsets property to left or right MGSwipeSettings.

Please, let me know if you are happy with the current implementation ;)

zizicici commented 7 years ago

I have built the demo, and I have an issue with 1.6.5.

Reproduce steps:

  1. Build the demo image

2.Swipe cell image

3.Rotate to landscape mode image

4.Swipe back the cell image

5.Rotate to portrait mode image

6.Swipe the cell image

MortimerGoro commented 7 years ago

@beimen Thanks a lot for the detailed info!

I have published 1.6.6 which better handles those edge cases like orientation changes. It also correctly handles Right to left languages now.

Please try the new version when you can ;)

zizicici commented 7 years ago

Good Job. Thanks @MortimerGoro .

But there is something wrong with my project. I used the 1.6.6, demo looks good, my project looks bad. And I find the cause: when I rotate the device, the timing of calling the -(void) setSafeInset:(CGFloat)safeInset extendEdgeButton:(BOOL) extendEdgeButton isRTL: (BOOL) isRTL in the demo is different with my project( Xcode 9.1 + Swift 4 + iOS 11.1 + iPhone X).

In the demo: image

In my project: image

The difference made the layout of cell become into a mess.

I cannot find the root cause for many days(Why is - (void)layoutSublayersOfLayer:(CALayer *)layer;, not cell.layoutSubviews()), but I think maybe other developers may have the same issue. If you have some ideas about my issue, please let me know.

MortimerGoro commented 7 years ago

@beimen It would be very helpful if you could send me a test project that reproduces the problem. It's difficult to guess the problem if I can't reproduce it on my projects.