This is an iOS control for presenting any UIView in an UIAlertController like manner

Overview

RMActionController Build Status Pod Version Carthage compatible

This framework allows you to present just any view as an action sheet. In addition, it allows you to add actions around the presented view which behave like a button and can be tapped by the user. The result looks very much like an UIActionSheet or UIAlertController with a special UIView and some UIActions attached.

RMActionController also contains two special actions (RMImageAction and RMScrollableGroupedAction) which allow to build a share sheet which looks very much like the UIActivityViewController. In addition, RMActionController can be configured to look like the new buy sheet which can be found in the iOS 11 App Store.

Screenshots

White

Custom View Image Actions Map Sheet
Custom Image Map Sheet

Black

Custom View Image Actions Map Sheet
Custom Image Map Sheet

Landscape

RMActionController supports automatic rotation between portrait and landscape.

Installation (CocoaPods)

platform :ios, '8.0'
pod "RMActionController", "~> 1.3.1"

Usage

For a detailed description on how to use RMActionController take a look at the Wiki Pages. The following four steps are a very short intro:

  • Create your own subclass of RMActionController. Let's create one for presenting a map and let's call it RMMapActionController:
@interface RMMapActionController : RMActionController<MKMapView *>
@end
  • In this subclass overwrite the initializer to add your own content view (for example to add a map as content view):
@implementation RMMapActionController

- (instancetype)initWithStyle:(RMActionControllerStyle)aStyle title:(NSString *)aTitle message:(NSString *)aMessage selectAction:(RMAction *)selectAction andCancelAction:(RMAction *)cancelAction {
    self = [super initWithStyle:aStyle title:aTitle message:aMessage selectAction:selectAction andCancelAction:cancelAction];
    if(self) {
        self.contentView = [[MKMapView alloc] initWithFrame:CGRectZero];
        self.contentView.translatesAutoresizingMaskIntoConstraints = NO;

        NSDictionary *bindings = @{@"mapView": self.contentView};
        [self.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"[mapView(>=300)]" options:0 metrics:nil views:bindings]];
        [self.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[mapView(200)]" options:0 metrics:nil views:bindings]];
    }
    return self;
}

@end
  • Present your custom RMActionController:
- (IBAction)openActionController:(id)sender {
    RMAction *selectAction = [RMAction<MKMapView *> actionWithTitle:@"Select" style:RMActionStyleDone andHandler:^(RMActionController<MKMapView *> *controller) {
        NSLog(@"Action controller selected location: %f, %f", controller.contentView.centerCoordinate.latitude, controller.contentView.centerCoordinate.longitude);
    }];

    RMAction *cancelAction = [RMAction<MKMapView *> actionWithTitle:@"Cancel" style:RMActionStyleCancel andHandler:^(RMActionController<MKMapView *> *controller) {
        NSLog(@"Action controller was canceled");
    }];

    RMMapActionController *actionController = [RMMapActionController actionControllerWithStyle:RMActionControllerStyleWhite title:@"Test" message:@"This is a map action controller.\nPlease select a location and tap 'Select' or 'Cancel'." selectAction:selectAction andCancelAction:cancelAction];

    //Now just present the action controller using the standard iOS presentation method
    [self presentViewController:actionController animated:YES completion:nil];
}
  • In case you really want to present a map you may want to disable blur effects for the map (as otherwise it will show as black):
@implementation RMMapActionController

- (BOOL)disableBlurEffectsForContentView {
    return YES;
}

@end

Migration

See Migration on how to migrate to the latest version of RMActionController.

Documentation

There is an additional documentation available provided by the CocoaPods team. Take a look at cocoadocs.org.

Requirements

Compile Time Runtime
Xcode 9 iOS 8
iOS 11 SDK
ARC

Note: ARC can be turned on and off on a per file basis.

Apps using this control

Using this control in your app or know anyone who does?

Feel free to add the app to this list: Apps using RMActionController

Credits

  • Hannes Tribus (Bugfixes)
  • normKei (Destructive button type)

I want to thank everyone who has contributed code and/or time to this project!

License (MIT License)

Copyright (c) 2015-2017 Roland Moers

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Comments
  • Unable to change the tintColor of Cancel button

    Unable to change the tintColor of Cancel button

    Hi, Thank you for all your hard work. This is an awesome tool. I was wondering if you can help me with this issue. I want to change the color of the Cancel button to be red and yet keep it as a "Cancel" style. Is this possible.?

    Thanks

    opened by d-shenoy 4
  • ActionController dismiss on background added

    ActionController dismiss on background added

    Dear,

    I've added 2 features to this project:

    1. UITextFields on ActionSheet and moving action sheet to top on textField click
    2. Dismissing ActionController on Background click.
    opened by farri 4
  • Tableview

    Tableview

    Hii guys,

    Iam tryng to add an tableview. I attached one print screen. What's do you think?

    screen shot 2016-01-07 at 17 30 02

    I can see the prints...the data is ok

    
        func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
        {
            print("came here = " + self.pickerData[indexPath.row])
            let cell:UITableViewCell = self.pickerView.dequeueReusableCellWithIdentifier("cell")! as UITableViewCell
            cell.textLabel?.text = self.pickerData[indexPath.row]
    
            if(indexPath.row % 2 == 0){
                cell.backgroundColor = UIColor.grayColor()
            } else{
                cell.backgroundColor = UIColor.whiteColor()
            }
    
            return cell
        }
    
    //where I add the tableview
      let newFrame4 = CGRectMake(0, 170, 300, 100)// 0 center - 120 top margin
            pickerView.frame = newFrame4
            self.contentView.addSubview(pickerView)
    
    
    opened by diogo10 4
  • App froze after present RMActionController on iOS 8

    App froze after present RMActionController on iOS 8

    on iOS 8, present RMActionController have a strange animation, and after animation, app froze here is preview https://vid.me/Yrpe

    Sample code:

    if let dateSelectionVC = RMDateSelectionViewController(style: .Default, selectAction: RMAction(title: "Select".localizedString, style: .Default, andHandler: { [weak sender] (controller: RMActionController!) in
    
      let date = (controller.contentView as! UIDatePicker).date
      sender?.setOrderDate(date)
    
    }), andCancelAction: RMAction(title: "Cancel".localizedString, style: .Cancel, andHandler: { _ in
    
    })) {
       dateSelectionVC.datePicker.datePickerMode = .Date
       dateSelectionVC.disableBlurEffects = true
       dateSelectionVC.disableBouncingEffects = true
       dateSelectionVC.datePicker?.date = date
       dateSelectionVC.datePicker?.maximumDate = NSDate()
    
       presentViewController(dateSelectionVC, animated: true, completion: nil)
    }
    
    opened by tiepvuvan 4
  • iPhone: black backgroundcolor on portrait orientation

    iPhone: black backgroundcolor on portrait orientation

    Hello,

    thank you for this great classes. I want to use RMActionController for an universal app and hope, you could help me with an issue with the background color of the presenting view controller. On iPhone devices the background color will change to black on portrait orientation. On landscape, the color is correct. On iPad it works well in both orientations.

    kind regards

    opened by bender75 3
  • The view of an RMActionController has been loaded before a contentView has been set - iOS 9

    The view of an RMActionController has been loaded before a contentView has been set - iOS 9

    Hi,

    Thank you for making this great library. I just have problem, I keep getting the following error:

    Error: The view of an RMActionController has been loaded before a contentView has been set. You have to set the contentView before presenting a RMActionController.

    Here is my code:

    -(void)display_choice_alert {
    
        // Create the custom alert view actions.
        RMAction *main_action = [RMAction actionWithTitle:@"Pizza menu" style:RMActionStyleDefault andHandler:^(RMActionController *controller) {
    
            NSLog(@"1");
        }];
    
        RMAction *side_action = [RMAction actionWithTitle:@"Side orders menu" style:RMActionStyleDefault andHandler:^(RMActionController *controller) {
    
            NSLog(@"2");
        }];
    
        RMAction *dismiss = [RMAction actionWithTitle:@"Dismiss" style:RMActionStyleCancel andHandler:^(RMActionController *controller) {
            NSLog(@"3");
        }];
    
        // Set the custom alert view properties and actions.
        RMActionController *actionController = [RMActionController actionControllerWithStyle:RMActionControllerStyleBlack selectAction:main_action andCancelAction:dismiss];
    
        // Add additional actions to the custom alert.
        [actionController addAction:side_action];
    
        // Set the custom alert details.
        actionController.title = @"Test";
        actionController.message = @"This is a test action controller.\nPlease tap 'Select' or 'Cancel'.";
    
        // Display the custom alert view.
        [self presentViewController:actionController animated:YES completion:nil];
    }
    

    Can you tell me what I am doing wrong here? I just followed your example thats all.

    Thanks for your time, Daniel.

    opened by Supertecnoboff 3
  • ActionController behind TabBar on iOS < 11

    ActionController behind TabBar on iOS < 11

    Hi,

    thanks for providing this control. It really makes building custom action sheets simple. Unfortunately I ran into a problem. If I am using a UITabBarController the action controller is presented behind the tab bar on the bottom.

    This problem only occurs on devices lower than iOS 11 as you can see in the screenshot.

    tabbar_issue

    Thanks a lot an kind regards,

    Phillipp

    opened by phillippbertram 2
  • Use system type for button when blur effects is disabled

    Use system type for button when blur effects is disabled

    One of my projects uses custom tint color for buttons. I would like to use this customization on this awesome control as well. :)

    Therefore to achieve this when the disableBlurEffects is set to YES the button is instantiated with UIButtonTypeSystem.

    opened by felipowsky 2
  • Disappeared title and message when using pure RMActionController without inheritance.

    Disappeared title and message when using pure RMActionController without inheritance.

    hello, CooperRS :) I can't show title and message at the top of controller when using basic RMActionController. It looks like dependent on layout constraints such as 'translatesAutoresizingMaskIntoConstraints' and entire VC's height. Must I write below codes for auto layout every inherited uiviewcontroller to show title and message?

    ...
    actionController.contentView.translatesAutoresizingMaskIntoConstraints = NO;
    ...
    NSDictionary *bindings = @{@"contentView": actionController.contentView};
            [actionController.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"[contentView(>=300)]" options:0 metrics:nil views:bindings]];
            [actionController.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[contentView(140)]" options:0 metrics:nil views:bindings]];
    

    i wrote like below (to add a MPVolumeView)

    RMActionController *actionController = [RMActionController actionControllerWithStyle:RMActionControllerStyleBlack
                                                                                           title:@"Test"
                                                                                         message:@"This is a test action controller.\nPlease tap 'Select' or 'Cancel'."
                                                                                    selectAction:nil
                                                                                 andCancelAction:nil];
    
            [actionController addAction:[RMAction actionWithTitle:@"Done" style:RMActionStyleDone andHandler:^(RMActionController *controller) {
    
            }]];
            actionController.disableBouncingEffects = YES;
            actionController.disableBlurEffectsForBackgroundView = YES;
    
            //On the iPad we want to show the map action controller within a popover. Fortunately, we can use iOS 8 API for this! :)
            //(Of course only if we are running on iOS 8 or later)
            if([actionController respondsToSelector:@selector(popoverPresentationController)] && [UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) {
                //First we set the modal presentation style to the popover style
                actionController.modalPresentationStyle = UIModalPresentationPopover;
                //Then we tell the popover presentation controller, where the popover should appear
    //            actionController.popoverPresentationController.sourceView = self.tableView;
    //            actionController.popoverPresentationController.sourceRect = [self.tableView rectForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
            }
    
            //Now just present the date selection controller using the standard iOS presentation method
            actionController.contentView = [[UIView alloc] initWithFrame:CGRectZero];
            actionController.contentView.translatesAutoresizingMaskIntoConstraints = NO;
    
            MPVolumeView * volumeView = [[MPVolumeView alloc] initWithSize:CGSizeMake(0,50)];
            volumeView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
            [actionController.contentView addSubview:volumeView];
    
    /*
            NSDictionary *bindings = @{@"contentView": actionController.contentView};
            [actionController.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"[contentView(>=300)]" options:0 metrics:nil views:bindings]];
            [actionController.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[contentView(140)]" options:0 metrics:nil views:bindings]];
    */
    
            [[UIApplication sharedApplication].keyWindow.rootViewController  presentViewController:actionController animated:YES completion:nil];
    

    and i hope to write like this (case for iphone only - just set contentview. and the end):

    RMActionController *actionController = [RMActionController actionControllerWithStyle:RMActionControllerStyleBlack
                                                                                           title:@"Test"
                                                                                         message:@"This is a test action controller.\nPlease tap 'Select' or 'Cancel'."
                                                                                    selectAction:nil
                                                                                 andCancelAction:nil];
    
            [actionController addAction:[RMAction actionWithTitle:@"Done" style:RMActionStyleDone andHandler:^(RMActionController *controller) {
    
            }]];
    
            actionController.disableBouncingEffects = YES;
            actionController.disableBlurEffectsForBackgroundView = YES;
    
    // just set contentview. and the end.
            actionController.contentView = [[MPVolumeView alloc] initWithSize:CGSizeMake(0,50)];
            actionController.contentView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
    
            [[UIApplication sharedApplication].keyWindow.rootViewController  presentViewController:actionController animated:YES completion:nil];
    
    opened by metasmile 2
  • Doesn't work in iOS 7 + fix

    Doesn't work in iOS 7 + fix

    Crashes in iOS 7.1 with message: dyld: Symbol not found: _UIAccessibilityIsReduceMotionEnabled

    Suggested fix (if there is a better fix let me know, I can submit a Pull request)

    • (BOOL)disableBouncingEffects { if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0) { if(&UIAccessibilityIsReduceMotionEnabled && UIAccessibilityIsReduceMotionEnabled()) { return YES; } } return _disableBouncingEffects; }
    • (BOOL)disableMotionEffects { if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0) { if(&UIAccessibilityIsReduceMotionEnabled && UIAccessibilityIsReduceMotionEnabled()) { return YES; } } return _disableMotionEffects; }
    opened by lorenzoPrimi 2
  • cancel by taping fixed for grouped actions

    cancel by taping fixed for grouped actions

    If you init the control with “Select” and “Cancel” the actions are stored in the doneActions array, which is not check when taping outside the control.

    + (instancetype)actionControllerWithStyle:(RMActionControllerStyle)style title:(NSString *)aTitle message:(NSString *)aMessage selectAction:(RMAction *)selectAction andCancelAction:(RMAction *)cancelAction {
        ...
        if(selectAction && cancelAction) {
            RMGroupedAction *action = [RMGroupedAction actionWithStyle:RMActionStyleDefault andActions:@[cancelAction, selectAction]];
            [controller addAction:action];
        ...
    }
    
    opened by hons82 2
  • Add support for Dark / Light theme with low transparency fallback

    Add support for Dark / Light theme with low transparency fallback

    This PR replaces the use of [UIColor whiteColor] as a container background when transparency / blur is disabled with the system-defined [UIColor secondaryBackgroundColor] on iOS 13+ as this color is impacted by dark/light mode.

    opened by NSMustache 0
  • Suggestion : Pb with Dark Mode

    Suggestion : Pb with Dark Mode

    Hi,

    In dark mode, the header title and header message, are not visible enough, and difficult to change. I suggest that you expose (public) the headers' properties (headerTitleLabel headerMessageLabel).

    opened by Droppix 0
  • Make changing font/text size/color of title labels customizable

    Make changing font/text size/color of title labels customizable

    Currently, the labels for title and message are not customizable at all.

    Requested in: https://github.com/CooperRS/RMDateSelectionViewController/issues/84

    enhancement 
    opened by CooperRS 0
  • Request to expose labels

    Request to expose labels

    Hey there,

    As far as I understand, the only way to modify the default fonts is by subclassing.

    Is there any chance you could expose those labels/buttons so we can modify them directly, instead of having to subclass? I'm currently having issues trying to subclass in Swift using Generics. I'm forced to create concrete subclasses and that's not ideal. :/

    I just want to modify the font for the title/description header text, as well as the RMAction buttons I add. Not just for RMActionController but also for the RMDateSelectionViewController.

    Is this something you would consider adding, a better way to modify default values without having to subclass? Even you don't want to expose the UI elements directly, using a custom "default styles" object/class would do the job as well.

    What do you think?

    enhancement 
    opened by jyounus 1
  • Missing property to specify border width (Default is 10)

    Missing property to specify border width (Default is 10)

    Hi,

    really appreciate your work.

    Would it be possible to add a property that allows a subclass to specify the border width to be used ?

    Currently the constraints are fixed to 10px when setting up the container constraints in setupConstraints. From a visual perspective it would fit better to my app if this was only 2px. The same issue I have with setupTopContainersTopMarginConstraint where you use a fixed size as well.

    So ideally one would be able to set the leading, trailing, top and bottom margin from a subclass using a public float property or a function that one could override in a subclass.

    enhancement 
    opened by Oggerschummer 1
Releases(1.3.1)
Owner
Roland Moers
Roland Moers
This is an iOS control for selecting something using UIPickerView in an UIAlertController like manner

RMPickerViewController This framework allows you to pick something with a picker presented as an action sheet. In addition, it allows you to add actio

Roland Moers 382 Dec 19, 2022
Use UIAlertController like a boss.

Description Requirements Installation CocoaPods Carthage Usage License Description CatAlertController is a high level manager object that with chainin

Kcat 8 Feb 8, 2022
A simple, customizable popup dialog for iOS written in Swift. Replaces UIAlertController alert style.

Introduction Popup Dialog is a simple, customizable popup dialog written in Swift. Features Easy to use API with hardly any boilerplate code Convenien

Orderella Ltd. 3.8k Dec 20, 2022
A customizable, full-feature, lightweight iOS framework to be used instead of UIAlertController.

A customizable, full-feature, lightweight iOS framework to be used instead of UIAlertController.

Ali Samaiee 11 Jun 6, 2022
A simple custom popup dialog view for iOS written in Swift. Replaces UIAlertController alert style.

A simple custom popup dialog view for iOS written in Swift. Replaces UIAlertController alert style.

donggyu 5 Jan 26, 2022
Swifty, modern UIAlertController wrapper.

Alertift Alertift.alert(title: "Alertift", message: "Alertift is swifty, modern, and awesome UIAlertController wrapper.") .action(.default("❤️"))

Suguru Kishimoto 287 Jan 7, 2023
Advanced usage of UIAlertController and pickers based on it: Telegram, Contacts, Location, PhotoLibrary, Country, Phone Code, Currency, Date...

Alerts & Pickers Advanced usage of native UIAlertController with TextField, TextView, DatePicker, PickerView, TableView, CollectionView and MapView. F

RV 5.5k Dec 22, 2022
An easier constructor for UIAlertController. Present an alert from anywhere.

ALRT An easier constructor for UIAlertController. Present an alert from anywhere like this. ALRT.create(.alert, title: "Alert?").addOK().addCancel().s

Masahiro Watanabe 97 Nov 11, 2022
Easy Swift UIAlertController

EZAlertController Easy Swift UIAlertController One line setup for all UIAlertControllers Button action with closures instead of selectors Easily custo

Kan Yilmaz 366 Sep 14, 2022
Simple UIAlertController builder class in Swift.

Kamagari Simple UIAlertController builder class in Swift. Features AlertBuilder class to simply build UIAlertController by using method chaining UIAle

Kazunobu Tasaka 78 Nov 29, 2022
PMAlertController is a great and customizable alert that can substitute UIAlertController

PMAlertController is a small library that allows you to substitute Apple's uncustomizable UIAlertController, with a beautiful and totally customizable

Paolo Musolino 2.5k Jan 3, 2023
PMAlertController is a great and customizable alert that can substitute UIAlertController

PMAlertController is a small library that allows you to substitute Apple's uncustomizable UIAlertController, with a beautiful and totally customizable

Paolo Musolino 2.5k Jan 3, 2023
Advanced usage of UIAlertController and pickers based on it: Telegram, Contacts, Location, PhotoLibrary, Country, Phone Code, Currency, Date...

Alerts & Pickers Advanced usage of native UIAlertController with TextField, TextView, DatePicker, PickerView, TableView, CollectionView and MapView. F

RV 5.5k Dec 26, 2022
Simple Alert View written in Swift, which can be used as a UIAlertController. (AlertController/AlertView/ActionSheet)

DOAlertController Simple Alert View written in Swift, which can be used as a UIAlertController replacement. It supports from iOS7! It is simple and ea

Daiki Okumura 406 Sep 5, 2022
An easy to use UIAlertController builder for swift

LKAlertController An easy to use UIAlertController builder for swift Features Short and simple syntax for creating both Alerts and ActionSheets from U

Lightning Kite 97 Feb 8, 2022
Customizable replacement for UIAlertController

ActionSheet Customizable replacement for UIAlertController. Requirements Installation Swift Package Manager The Swift Package Manager is a tool for au

Horizontal Systems 0 Oct 6, 2022
UIAlertController with continuity.

CuckooAlert Allow multiple use of presentViewController to UIAlertController. You may be disappointed from this. Do you imagine that cuckoo spit out s

Jay Choi 5 Feb 2, 2020
UIPicker inside a UIAlertController

DPPickerManager UIPicker inside a UIAlertController HOW TO USE : // Strings Picker let values = ["Value 1", "Value 2", "Value 3", "Value 4"] DPPickerM

Prioregroup.com 45 May 30, 2022
An easier constructor for UIAlertController. Present an alert from anywhere.

ALRT An easier constructor for UIAlertController. Present an alert from anywhere like this. ALRT.create(.alert, title: "Alert?").addOK().addCancel().s

Masahiro Watanabe 97 Nov 11, 2022