XLActionController icon indicating copy to clipboard operation
XLActionController copied to clipboard

Reload number of actions

Open RealBug opened this issue 8 years ago • 3 comments

Hi,

Is it a possibility to reload the number of actions when the action sheet is show ? For example, I wait for a web service call to hide a row.

Thx

RealBug avatar Dec 05 '16 13:12 RealBug

Hi @RealBug,

This is not actually natively supported by the library. But there is something that you can do, take a look to the code below:

@IBAction func tapGestureDidRecognize(_ sender: UITapGestureRecognizer) {
        let actionController = YoutubeActionController()
        actionController.addAction(Action(ActionData(title: "Add to Watch Later", image: UIImage(named: "yt-add-to-watch-later-icon")!), style: .default, handler: { action in
        }))
        actionController.addAction(Action(ActionData(title: "Add to Playlist...", image: UIImage(named: "yt-add-to-playlist-icon")!), style: .default, handler: { action in
        }))

        present(actionController, animated: true, completion: nil)

        DispatchQueue.main.asyncAfter(deadline: .now() + 5, execute: {
            actionController.addAction(Action(ActionData(title: "Share...", image: UIImage(named: "yt-share-icon")!), style: .default, handler: { action in
            }))
            actionController.addAction(Action(ActionData(title: "Cancel", image: UIImage(named: "yt-cancel-icon")!), style: .cancel, handler: nil))
            actionController.collectionView.reloadData()
            actionController.collectionView.contentInset = UIEdgeInsets(top: 556, left: 0, bottom: 0,         
        })
}

adding_actions

With some effort you might refresh the collectionView with some animation.

m-revetria avatar May 02 '17 20:05 m-revetria

Hi @m-revetria Thanks for your answer. Its a good solution to add rows but in my case I want to remove rows. You have no delete action it seems to me, right? :(

RealBug avatar May 02 '17 20:05 RealBug

Oh too bad. You're right, at this moment there is no way to remove an action from an action controller. Depending on your use case, maybe you can implement it in the opposite way by adding the actions that you are trying to remove now after you are sure they are valid options.

We are going to take this into account for the next release.

Thanks!

m-revetria avatar May 04 '17 14:05 m-revetria