CocoaPods trunk is moving to be read-only. Read more on the blog, there are 18 months to go.
TestsTested | ✓ |
LangLanguage | Obj-CObjective C |
License | Apache 2 |
ReleasedLast Release | Jan 2015 |
Maintained by Mouhcine El Amine.
UIActionSheet
has been deprecated starting iOS 8 and replaced by UIAlertController
which offers a better interface. Unfortunately if you have to support older versions of iOS in your application, you still have to use UIActionSheet
. The bad news is that UIActionSheet
's implementation starting iOS 8 has changed and presents different bugs.
SBTActionController
comes with an interface as close as possible to UIAlertController
. Under the hood it uses UIAlertController
if available, otherwise falls back to using UIActionSheet
.
To run the example project, clone the repo, and run pod install
from the Example directory first.
Then open the example workspace.
Requires Xcode 6 or higher and iOS SDK 8.0 or higher to compile. Runs on previous versions of iOS SDK but tested only on iOS 7.
Create the action controller
SBTActionController *actionController = [SBTActionController actionControllerWithTitle:NSLocalizedString(@"Are you sure?", nil)
message:NSlocalizedString(@"Deleting the item is irreversable", nil)];
Create the actions you want to present to the user and add them to action controller
// Create the actions you want to present to the user
SBTAction *deleteAction = [SBTAction actionWithTitle:NSLocalizedString(@"Delete item", nil)
style:UIAlertActionStyleDestructive
handler:^(SBTAction *action) {
// delete item
}];
[actionController addAction:deleteAction];
SBTAction *modifyAction = [SBTAction actionWithTitle:NSLocalizedString(@"Modify item", nil)
style:UIAlertActionStyleDefault
handler:^(SBTAction *action) {
// modify item
}];
[actionController addAction:modifyAction];
SBTAction *cancelAction = [SBTAction actionWithTitle:NSLocalizedString(@"Cancel", nil)
style:UIAlertActionStyleCancel
handler:NULL];
[actionController addAction:cancelAction];
Then present it
[actionController presentActionsFromBarButtonItem:barButtonItem
inViewController:self
animated:YES
completion:NULL];
Contributions are welcome! If you have a bug to report, feel free to help out by opening a new issue or sending a pull request.
SBTActionController is available under the Apache License, Version 2.0. See the LICENSE file for more info.