今天分享 ImagePicker 如何使用相机拍照
拉一个 Button 、 ImageView
在 Info.plist 添加一个 key,描述访问权限。
打开 Info.plist。
右键单击信息属性列表并选择添加行。出现一个新行。
输入 Key:
Main nib file base name
// 指定应用程序主 nib 文件的名称
Privacy - Camera Usage Description
// 使用相机的权限
在 Privacy - Camera Usage Description 的 Value 中,输入使用相机理由。当 iOS 首次请求访问库的权限时,它会显示此信息。
在 @IBAction 里
写一个 Alert 侦测是否有相机功能
没有相机 -> print("ERROR:没有相机功能!")
if !UIImagePickerController.isSourceTypeAvailable(.camera) {
let alertController = UIAlertController(title: "ERROR", message: "Device has no camera.", preferredStyle: .alert)
let okAction = UIAlertAction(title: "Alright", style: .default, handler: { (alert: UIAlertAction!) in
})
alertController.addAction(okAction)
self.present(alertController, animated: true, completion: nil)
print("ERROR:没有相机功能!")
} else { // 若有相机功能,将执行的事 }
明天会分享如何用 extension 去写 UIImagePickerControllerDelegate 的委任,敬请期待!
>>: [Day 26 - 小试身手] Todolist with React (1)
练习刻板面时常常会遇到形形色色的字体 但若不是电脑本身有下载该字体的话,即便设定了还是会以预设字体呈...
1. = =是判别左右相等为真 != 是判别左右不相等为真 2.function同名字,会执行後面的...
这段期间,我们用 Template Driven Forms 与 Reactive Forms 各...
tags: 2021铁人赛 React 安装styled-components套件 在专案资料夹内一...
您是否希望提高您的竞争地位? 应对外部威胁?识别新的机会或风险? 扩大您在新市场的影响力? 战略分...