Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reload number of actions #44

Open
RealBug opened this issue Dec 5, 2016 · 3 comments
Open

Reload number of actions #44

RealBug opened this issue Dec 5, 2016 · 3 comments

Comments

@RealBug
Copy link

RealBug commented Dec 5, 2016

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

@m-revetria
Copy link
Member

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.

@RealBug
Copy link
Author

RealBug commented May 2, 2017

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? :(

@m-revetria
Copy link
Member

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Roadmap v4
Code review
Development

No branches or pull requests

3 participants