XLActionController
XLActionController copied to clipboard
Reload number of actions
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
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,
})
}
With some effort you might refresh the collectionView with some animation.
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? :(
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!