需求如下:
点击按钮弹出如下选项。具体实现方式如下:
代码块
@property (nonatomic,strong)UIAlertController *alert;
-(UIAlertController *)alert{
if (!_alert) {
_alert = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
__weak __typeof(&*self)weakSelf = self;
[_alert addAction:[UIAlertAction actionWithTitle:@"新建维修记录" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
__strong __typeof(&*weakSelf)strongSelf = weakSelf;
SCEMCreateVC *vc = [[SCEMCreateVC alloc] init];
vc.scPageConfigKey = @"DEVICE/DETAIL/SERVICE/CREATE";
vc.appKey = @"FMP";
vc.areaId = self.areaId;
vc.deviceDetailModel = self.interactor.deviceDetail;
[strongSelf.navigationController pushViewController:vc animated:YES];
}]];
[_alert addAction:[UIAlertAction actionWithTitle:@"新建保养记录" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
__strong __typeof(&*weakSelf)strongSelf = weakSelf;
SCCreateMaintenanceVC *vc = [[SCCreateMaintenanceVC alloc] init];
vc.scPageConfigKey = @"DEVICE/MAINTENANCE/CREATE";
vc.appKey = @"FMP";
vc.areaId = self.areaId;
vc.deviceDetailModel = self.interactor.deviceDetail;
[strongSelf.navigationController pushViewController:vc animated:YES];
}]];
[_alert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
__strong __typeof(&*weakSelf)strongSelf = weakSelf;
[strongSelf.alert dismissViewControllerAnimated:YES completion:nil];
}]];
}
return _alert;
}
网友评论