- April 27, 2024
- Mins Read
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.
Custom View | Image Actions | Map | Sheet |
---|---|---|---|
Custom View | Image Actions | Map | Sheet |
---|---|---|---|
RMActionController
supports automatic rotation between portrait and landscape.
platform :ios, ‘8.0’
pod “RMActionController”, “~> 1.3.1”
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:
RMActionController
. Let’s create one for presenting a map and let’s call it RMMapActionController
:
@interface RMMapActionController : RMActionController<MKMapView *>
@end
@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
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];
}
@implementation RMMapActionController
– (BOOL)disableBlurEffectsForContentView {
return YES;
}
@end
See Migration on how to migrate to the latest version of RMActionController.
There is an additional documentation available provided by the CocoaPods team. Take a look at cocoadocs.org.
Compile Time | Runtime |
---|---|
Xcode 9 | iOS 8 |
iOS 11 SDK | |
ARC |
Note: ARC can be turned on and off on a per file basis.
Using this control in your app or know anyone who does?
Feel free to add the app to this list: Apps using RMActionController
Horizon SDK is a state of the art real-time video recording / photo shooting iOS library. Some of the features ...