Saturday, August 8, 2015

how to create code for taking photo

success as a part of project.
http://www.ioscreator.com/tutorials/take-photo-tutorial-ios8-swift
still struggling with this though ( http://www.techotopia.com/index.php/An_Example_Swift_iOS_8_iPhone_Camera_Application)

import UIKit

var imagePicker: UIImagePickerController!

class ViewController: UIViewController ,UINavigationControllerDelegate, UIImagePickerControllerDelegate{



    @IBOutlet var imageView: UIImageView!
    
    @IBAction func takePhoto(sender: UIButton) {
        imagePicker = UIImagePickerController()
        imagePicker.delegate = self
        imagePicker.sourceType = .Camera
        
        presentViewController(imagePicker, animated: true, completion: nil)
        
    }
    
    func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [NSObject :AnyObject]){

    imagePicker.dismissViewControllerAnimated(true, completion: nil)
    imageView.image = info [UIImagePickerControllerOriginalImage] as? UIImage
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


}


No comments:

Post a Comment