美文网首页iOS开发实用技术
iOS -UIImagePickerController单独设置

iOS -UIImagePickerController单独设置

作者: codemovie | 来源:发表于2018-10-22 12:56 被阅读174次
    • UIImagePickerController想必是个很常用的控件,在使用中发现,pickerController默认创建出来同时可以拍摄照片或者是拍摄视频,如下:
    UIImagePickerController *systemImagePicker = [[UIImagePickerController alloc]init];
        systemImagePicker.delegate = self;
        systemImagePicker.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypeCamera];
        systemImagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
        [self presentViewController:systemImagePicker animated:YES completion:nil];
    
    • 如只需要拍照模式,不用设置mediaTypes即可。
    UIImagePickerController *systemImagePicker = [[UIImagePickerController alloc]init];
        systemImagePicker.delegate = self;
        //systemImagePicker.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypeCamera];
        systemImagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
        systemImagePicker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;//设置摄像头捕获类型
        [self presentViewController:systemImagePicker animated:YES completion:nil];
    

    转载一篇文章,关于UIImagePickerController讲的很全,作为记录:
    UIImagePickerController

    相关文章

      网友评论

        本文标题:iOS -UIImagePickerController单独设置

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