I want to implement an action that starts when the camera screen switches after shooting.

Asked 2 years ago, Updated 2 years ago, 114 views

"When you press the button, the camera starts, and when the camera screen is switched to the main view, the image you are adding to the view disappears."
I'd like to make it a specification, but it doesn't work.
What should I do to make it work?

I want to run yagi.hidden=true; after closing the camera screen, so I put it in the back.

import UIKit

classViewController: UIViewController, UIImagePickerControllerDelegate, 
 US>UINavigationControllerDelegate{

override func viewDidLoad(){
        super.viewDidLoad()
   let myImage=UIImage(named: "ume")
            um.image=myImage
  }

@IBOutlet weak varyagi: UIImageView!

@ IBAction funclaunchCamera (sender: UIButton) {

let camera = UIImagePickerControllerSourceType.Camera

if UIImagePickerController.isSourceTypeAvailable(camera){
letpicker=UIImagePickerController()
picker.sourceType=camera
picker.delegate=self
self.presentViewController(picker, animated:true, completion:nil)
  }

funcimagePickerController(picker:UIImagePickerController, 
 DidFinishPickingMediaWithInfo: [String:AnyObject]) {

let image=info [UIImagePickerControllerOriginalImage] as!UIImage
UIImageWriteToSavedPhotosAlbum (image, nil, nil, nil)
self.dismissViewControllerAnimated(true, completion:nil)

yagi.hidden=true;

   }
  } 

}

ios swift xcode camera

2022-09-30 19:45

1 Answers

self.dismissViewControllerAnimated(true, completion:nil)
Completion of is performed after view is missed, so completion is

 {[unowned self] inself.yagi.hidden=true}

I think it would be good to pass it over and do it.


2022-09-30 19:45

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.