Eureka: SwipeAction not working in iOS 10

Created on 15 Mar 2018  路  12Comments  路  Source: xmartlabs/Eureka

Can be easily reproduced using a 10.3.1 simulator with the example app (in my case I'm using an iPad 5th gen 10.3.1).

If you try to tap the destructive button (or the more), nothing happens.

Current workaround I do is:

    if #available(iOS 11, *) {
    } else {
        if let section = self?.form.sectionBy(tag: "membersSection"), let indexPath = row.indexPath {
            section.remove(at: indexPath.row)
        }
    }

    completionHandler?(true)

All 12 comments

Swipe actions are new in iOS 11...

@arakweker I'm talking about the SwipeActions file in Eureka (https://github.com/xmartlabs/Eureka/blob/1ac7c98793ee1fdaae204fb87c9ea8f0001b8ef9/Source/Core/SwipeActions.swift). See in the README https://github.com/xmartlabs/Eureka#swipe-actions

It looks like the completion handler is never called under iOS 10

Yep... look at that page... scroll down...

@available(iOS 11.0, *)
extension UIContextualAction: ContextualAction {}

public protocol ContextualStyle{}
extension UITableViewRowActionStyle: ContextualStyle {}

@available(iOS 11.0, *)
extension UIContextualAction.Style: ContextualStyle {}

Looks like they are extensions to the swipeactions in iOS 11

@arakweker The class has support for pre iOS 11 using UITableViewRowAction which is available since iOS 8. Try to run the demo using iOS 10.x device and tap one of the row action, nothing happens.

@marbetschar Do you have time to look at it?

@allaire unfortunately I can't reproduce the falsy behaviour on my end. I just checked out master and ran the iOS Simulator 10.3.1. I can see the expected print statements in the console.

FWIW: As you can see in the Example app, you as a developer are responsible for calling the passed in completionHandler (if there is any available):

let deleteAction = SwipeAction(style: .destructive, title: "Delete") { (action, row, completionHandler) in
    print("Delete")
    completionHandler?(true)
}

This is expected and due to the design how UIContextualAction is working from iOS 11 onwards.

@allaire doh! Now I got what you mean, it really seems like the completionHandler of the underlying RowAction does not get called and therefore the buttons are not closed.

Investigating...

Pull request added to handle the animations for iOS <= 10 in the completionHandler, so they behave like iOS >= 11.

https://github.com/xmartlabs/Eureka/pull/1477

@mtnbarreto can you please have a look so we can get this merged?
@allaire thanks for pointing this out!

Yay thanks @marbetschar sorry if I wasn't clear with the issue in my first post :)

@marbetschar Thanks for fixing it!!

Was this page helpful?
0 / 5 - 0 ratings