美文网首页
UIAlertController

UIAlertController

作者: 羊妞麻麻 | 来源:发表于2018-11-01 16:47 被阅读17次

需求如下:
点击按钮弹出如下选项。具体实现方式如下:

屏幕快照 2018-11-01 下午4.17.17.png

代码块

@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;
}

相关文章

网友评论

      本文标题:UIAlertController

      本文链接:https://www.haomeiwen.com/subject/fcpxxqtx.html