• 图片选择器(UIImagePickerController)


    1、// 1.判断数据源是否可用

        if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {

            // 2.打开相册

            UIImagePickerController *ivPic = [[UIImagePickerController alloc] init];

            ivPic.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

            // 3.设置代理

            ivPic.delegate = self;

            // 4.显示图片选择器

            [self presentViewController:ivPic animated:YES completion:nil];

        }

    2、实现下面的代理方法
    (默认实现了下面的方法后,就需要手机释放图片选择器了)
    - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info

    {

        // 1.取出选中的图片

        UIImage *image =  info[UIImagePickerControllerOriginalImage];

        // 2.设置图片到imageview上

        self.iconView.image = image;

        // 3.关闭图片选择器

        [picker dismissViewControllerAnimated:YES completion:nil];

    }

  • 相关阅读:
    PHP的五大运行模式
    PHP设计模式-工厂模式
    php+redis实现消息队列
    面试题一
    Linux常用命令
    实现session在多台服务器上共享
    Memcache和redis的区别
    PHP设计模式-建造者模式
    FASTCgi和PHP-fpm关系
    安装vm虚拟机
  • 原文地址:https://www.cnblogs.com/bluceZ/p/3935999.html
Copyright © 2020-2023  润新知