Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS

Genady Novak
Genady Novak
5,164 Points

UIImagePickerController

I'm trying to present UIimageController with animation. The default animation present the UIimageController from bottom to top. How to present UIimageController from top to bottom

(I'm using swift)

Thanks!!

4 Answers

Noah Hanover
Noah Hanover
13,272 Points

Use the self.dismissViewController function. It took me FOREVER to find this out. I hope it works!

Genady Novak
Genady Novak
5,164 Points

I have UItabBarViewController with bar button that should activate the camera (the same as Instagram). if I will dismiss the view controller it will not present me the camera

Noah Hanover
Noah Hanover
13,272 Points

I'm not sure that I follow what you are saying. Can you post some of the code up, so that I can take a look?

Genady Novak
Genady Novak
5,164 Points

The following UIViewController Class is one to the views that loads from my UITabBarController

import Foundation import MobileCoreServices

class CameraView: UIViewController , UINavigationControllerDelegate, UIImagePickerControllerDelegate { var image : UIImage! var imagePicker : UIImagePickerController!

override func viewWillAppear(animated: Bool) {
    super.viewWillAppear(animated)
    self.showCamera()

}


func showCamera(){
    if self.image == nil{

        self.imagePicker = UIImagePickerController()
        self.imagePicker?.delegate = self
        self.imagePicker?.allowsEditing = false
        if (UIImagePickerController.isSourceTypeAvailable(.Camera)){
            self.imagePicker?.sourceType = .Camera
        }
        self.imagePicker?.mediaTypes = [kUTTypeImage!]
        self.presentViewController(self.imagePicker!, animated: false, completion: nil)
    }
}

func imagePickerControllerDidCancel(picker: UIImagePickerController) {
    self.tabBarController?.selectedIndex = 0
    self.dismissViewControllerAnimated(false, completion: nil)
}

}

Noah Hanover
Noah Hanover
13,272 Points

I understand, you are trying to Present the ViewContoller, but with the same animation as dismissViewControllerAnimated has. I'm sorry, but I'm not sure how to do this. If you look at maybe some stackOverFlow questions, you may be able to find out. If not, try finding a different way to present a view controller

Genady Novak
Genady Novak
5,164 Points

Ok thanks for the help