Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

santoshkc

macrumors newbie
Original poster
Jun 30, 2016
1
0
Kathmandu
Hello, I am working on a project that uses tabbar system. One of the item of tabbar is JobPostingViewController. I Embed it in UINavigationController. There is a UIButton called add new job in this view controller .I implemented pushviewcontroller to go CreateJobPostViewController. There I need to add UIImagePickerController to choose the image. When i tap done button or choose an image from library it dismisses to JobPostingViewController. But it should go to the CreateJobPostViewController.
Any one please help me. Thanks in advance.
Code in JobPostingViewController
Code:
 @IBAction func openCreateJob(sender: AnyObject) {
        let vc = self.storyboard?.instantiateViewControllerWithIdentifier("CreateJobPostViewController") as! CreateJobPostViewController
        self.navigationController?.pushViewController(vc, animated: true)
    }

code in CreateJobPostViewController
Code:
override func viewDidLoad() {
    super.viewDidLoad()
    imagePicker.delegate = self
}
//MARK:- IBActions
@IBAction func addImages(sender: AnyObject) {
    imagePicker.allowsEditing = false
    imagePicker.sourceType = .PhotoLibrary 
    presentViewController(imagePicker, animated: true, completion: nil)
}

// this for did finish picker view controller
     func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) {
        picker.dismissViewControllerAnimated(true, completion: nil)
    }

// for cancel picker view controller
func imagePickerControllerDidCancel(picker: UIImagePickerController!)
{
    picker.dismissViewControllerAnimated(true, completion: nil)
}
 

Attachments

  • ezgif.com-video-to-gif-2.gif
    ezgif.com-video-to-gif-2.gif
    470.5 KB · Views: 196
Last edited:
I'm pretty sure you need to call - dismissViewControllerAnimated:: on the presenting view controller, which would be "self", not picker.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.