view添加在window上面 在view上彈出UIAlertController

首先呢spa

UIAlertController是presentViewController  屬於模型跳轉 模型是vc才能夠present  因此把添加在window上面的view賦值個vc  在vc上面進去presentit

    AppDelegate *delegate =(id)[UIApplication sharedApplication].delegate;io

    UIViewController *vc = [[UIViewController alloc] init];//實例化一個vcim

    vc.view = self.typeView;//self.typeView這個是添加在window上面的viewanimate

    [delegate.window addSubview:vc.view];//添加view

 

    /*  彈出相冊   */vi

    WS(weakself);handler

    _typeView.block = ^{co

 

        UIAlertController *alertVc = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];block

        UIAlertAction *cancle = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction *_Nonnull action) {

 

        }];

 

        UIAlertAction *camera = [UIAlertAction actionWithTitle:@"打開相機" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {

            [weakself takePhoto];

 

        }];

 

        UIAlertAction *picture = [UIAlertAction actionWithTitle:@"打開相冊" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {

 

            [weakself localPhoto];

        }];

        [alertVc addAction:cancle];

        [alertVc addAction:camera];

        [alertVc addAction:picture];

        [vc presentViewController:alertVc animated:YES completion:nil];

    };

相關文章
相關標籤/搜索