Search
 
SCRIPT & CODE EXAMPLE
 

SWIFT

Allow user to import image

import UIKit


class ViewController: UIViewController, UINavigationControllerDelegate, UIImagePickerControllerDelegate {

    @IBOutlet var imageView: UIImageView!
    @IBOutlet var chooseBuuton: UIButton!
    var imagePicker = UIImagePickerController()

    @IBAction func btnClicked() {

        if UIImagePickerController.isSourceTypeAvailable(.savedPhotosAlbum){
            print("Button capture")

            imagePicker.delegate = self
            imagePicker.sourceType = .savedPhotosAlbum
            imagePicker.allowsEditing = false

            present(imagePicker, animated: true, completion: nil)
        }
    }

    func imagePickerController(picker: UIImagePickerController!, didFinishPickingImage image: UIImage!, editingInfo: NSDictionary!){
        self.dismiss(animated: true, completion: { () -> Void in

        })

        imageView.image = image
    }
}
Comment

PREVIOUS NEXT
Code Example
Swift :: swift print statement 
Swift :: swift methods 
Swift :: xib image shown on simulator but not on device 
Swift :: Nested Loops in Swift 
Swift :: Used with Collections Swift 
Swift :: protocol oriented programming 
Swift :: jsonserialization swift 
Swift :: key path expression as functions ios swift 
Swift :: declare multiple variables at once in swift 
Swift :: Swift Function Overloading 
Swift :: Swift Add Elements to a Dictionary 
Swift :: Convert struct to JSON string in swift 5 
Swift :: swift toggle on change 
Swift :: allowed filename characters swift 
Ruby :: 2 decimal places ruby 
Ruby :: rails image tag 
Ruby :: rails generate migration array default value 
Ruby :: how to create migration with uniqueness inrails 
Ruby :: rails get source method 
Ruby :: remove first element from an array ruby 
Ruby :: rails naming conventions controller 
Ruby :: ruby get decimal 
Ruby :: sort array of hashes ruby 
Ruby :: create a new hash from existing hash ruby 
Ruby :: ruby for loop 
Ruby :: rails keep all params except for some 
Ruby :: require multiple files ruby 
Ruby :: rails loop through datetime 
Ruby :: generate view rails 
Ruby :: ! in ruby 
ADD CONTENT
Topic
Content
Source link
Name
9+7 =