ios - UIImagePicker source type doesn't want to change -


i've set uiimagepicker .savedphotosalbum sourcetype in order develop app.

import uikit  class pictureviewcontroller: uiviewcontroller, uiimagepickercontrollerdelegate, uinavigationcontrollerdelegate {      /////////////////// outlets ////////////////////     ///////////////// properties ///////////////////     var imagepicker = uiimagepickercontroller()  override func viewdidload() {         super.viewdidload()          imagepicker.delegate = self      }  func imagepickercontroller(_ picker: uiimagepickercontroller, didfinishpickingmediawithinfo info: [string : any]) {         // want our photos , don't want edited photos         imagepicker.allowsediting = false         imagepicker.sourcetype = uiimagepickercontrollersourcetype.camera         imagepicker.cameracapturemode = .photo         imagepicker.modalpresentationstyle = .fullscreen          // let's take image picker         let image = info[uiimagepickercontrolleroriginalimage] as! uiimage         snapimage.image = image          // when user picks picture, disabling background color of uiimageview         snapimage.backgroundcolor = uicolor.clear          // closing image picker         imagepicker.dismiss(animated: true, completion: nil)     }      @ibaction func cameratapped(_ sender: any) {         present(imagepicker, animated: true, completion: nil)     } 

now app finished want try app on iphone changed :

imagepicker.sourcetype = .savedphotosalbum 

to

imagepicker.sourcetype = uiimagepickercontrollersourcetype.camera 

and have added in info.plist

<key>nscamerausagedescription</key>     <string>we want access camera ...</string> 

but when try take picture, keeps showing me photos album , problem. want able take picture camera of phone.

you need put code

imagepicker.allowsediting = false imagepicker.sourcetype = uiimagepickercontrollersourcetype.camera imagepicker.cameracapturemode = .photo imagepicker.modalpresentationstyle = .fullscreen 

in either viewdidload or cameratapped

problem - right putting code in delegate method of uiimagepicker gets called after either picking image or taking image.


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -