RMActionController 1.3.1

RMActionController 1.3.1

测试测试通过
语言语言 Obj-CObjective C
许可协议 MIT
发布最后发布2017年9月

Roland Moers维护。




  • Roland Moers

此框架允许您将任何视图作为操作表显示。此外,它允许您在显示的视图周围添加操作,这些操作类似于按钮,用户可以触摸。结果是看起来非常像具有特殊UIView和某些UIActions附加的UIActionSheetUIAlertController

RMActionController还包含两个特殊操作(RMImageActionRMScrollableGroupedAction),允许构建一个类似于UIActivityViewController的分享表。此外,RMActionController可以进行配置,看起来像iOS 11应用商店中可以找到的新购买表。

屏幕截图

白色

自定义视图 图片操作 地图 表单
Custom Image Map Sheet

黑色

自定义视图 图片操作 地图 表单
Custom Image Map Sheet

横向

RMActionController支持在竖屏和横屏之间自动旋转。

使用说明

关于如何使用RMActionController的详细信息,请查看Wiki页面。以下四个步骤是一个非常简短的介绍

  • 创建自己的RMActionController子类。让我们创建一个用于显示地图的子类,并将其称为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

移植

有关移植到RMActionController最新版本的说明,请参阅移植

文档

CocoaPods团队还提供额外的文档。请参阅cocoadocs.org

要求

编译时间 运行时间
Xcode 7 iOS 8
iOS 9 SDK
ARC

注意:可以在文件级别上打开和关闭ARC。

使用此控件的应用

您是否在自己的应用中使用此控件,或认识任何正在使用的人?

请随意将应用添加到以下列表中:使用 RMActionController 的应用

感谢

  • Hannes Tribus(错误修复)
  • normKei(破坏性按钮类型)

我想感谢所有为这个项目贡献代码和时间的人!

许可证(MIT 许可证)

Copyright (c) 2015-2016 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.