zoukankan      html  css  js  c++  java
  • view添加在window上面 在view上弹出UIAlertController

    首先呢

    UIAlertController是presentViewController  属于模型跳转 模型是vc才可以present  所以把添加在window上面的view赋值个vc  在vc上面进去present

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

        UIViewController *vc = [[UIViewController alloc] init];//实例化一个vc

        vc.view = self.typeView;//self.typeView这个是添加在window上面的view

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

        /*  弹出相册   */

        WS(weakself);

        _typeView.block = ^{

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

            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];

        };

  • 相关阅读:
    一、汇编基础知识
    PHP RabbitMQ消息队列演示代码
    PHP CentOS下安装PHP及部署ThinkPHP
    MySQL CentOS下安装MySQL
    ThinkPHP 对接支付宝支付接口
    ThinkPHP 获取当前页面完整的URL地址
    前端 Validform.js属性,用法及Ajax提交简介
    PHP 配置Xdebug调试工具
    ThinkPHP 原生分页功能改进,更好用更美观
    ThinkPHP 使用第三方phpmailer库发送邮件
  • 原文地址:https://www.cnblogs.com/liaolijun/p/9754896.html
Copyright © 2011-2022 走看看