UIImagePickerController messing tabbar frame when dismissing

好久不见. 提交于 2019-12-08 04:54:48

问题


I am trying to show a UIImagePickerController in a UIViewController inside a UITabBarController

SourceType Camera
MediaType kUTTypeMovie

There's no issue presenting the UIImagePickerController, but when dismissed the TabBar moves down half the height, it only happens sometimes... other it dismisses perfectly.

override func viewDidLoad() {

    var test: UIButton = UIButton(frame:CGRectMake(140, 200, 100, 100))
    test.backgroundColor = UIColor.redColor()
    test.addTarget(self, action:"presentCamera", forControlEvents: .TouchDown)
    self.view.addSubview(test)
}

func presentCamera(){
    if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.Camera){
        imag.mediaTypes = [kUTTypeMovie]
        imag.delegate = self
        imag.sourceType = UIImagePickerControllerSourceType.Camera;
        imag.videoQuality = UIImagePickerControllerQualityType.TypeMedium
        imag.videoMaximumDuration = 120
        imag.allowsEditing = false
        self.presentViewController(imag, animated: true, completion:{println("showing")})
    }

}

func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [NSObject : AnyObject]) {
    let library = ALAssetsLibrary()
    var videoTemp = info[UIImagePickerControllerMediaURL] as NSURL
    videoPath = videoTemp.relativePath
    UISaveVideoAtPathToSavedPhotosAlbum(videoPath, self, nil, nil)
    picker.dismissViewControllerAnimated(true, completion:{
        println("video selected")
    })    
}

func imagePickerControllerDidCancel(picker: UIImagePickerController) {
    picker.dismissViewControllerAnimated(true, completion:{
        println("canceled")
    })
}

It is also displaying this error:

"Snapshotting a view that has not been rendered results in an empty snapshot. Ensure your view has been rendered at least once before snapshotting or snapshot after screen updates."

Here is a video of how the app and the error looks:

https://www.youtube.com/watch?v=o1BgLbZgsfw


回答1:


It was already asked here:

Redbar Noticed when dismissing UIImagePickerController

I also noticed the red status bar when dismissing, solved using this:

you should set "View controller-based status bar appearance" value to YES in the .plist



来源:https://stackoverflow.com/questions/28075126/uiimagepickercontroller-messing-tabbar-frame-when-dismissing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!