此框架允许您将任何视图作为操作表显示。此外,它允许您在显示的视图周围添加操作,这些操作类似于按钮,用户可以触摸。结果是看起来非常像具有特殊UIView
和某些UIActions
附加的UIActionSheet
或UIAlertController
。
RMActionController
还包含两个特殊操作(RMImageAction
和RMScrollableGroupedAction
),允许构建一个类似于UIActivityViewController
的分享表。此外,RMActionController
可以进行配置,看起来像iOS 11应用商店中可以找到的新购买表。
自定义视图 | 图片操作 | 地图 | 表单 |
---|---|---|---|
自定义视图 | 图片操作 | 地图 | 表单 |
---|---|---|---|
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 的应用
我想感谢所有为这个项目贡献代码和时间的人!
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.