UIImagePickerController

UIImagePickerController

本文介绍了关闭时的UIImagePickerController混乱的标签栏框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在UITabBarController内的UIViewController中显示UIImagePickerController

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

SourceType摄像头
MediaType kUTTypeMovie

SourceType Camera
MediaType kUTTypeMovie

呈现UIImagePickerController没问题,但是当解开TabBar向下移动一半高度时,它只会在某些情况下发生……其他情况则完全消除.

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")
    })
}

它也显示此错误:

以下是有关应用程序和错误外观的视频:

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

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

推荐答案

在这里已经有人问过了:

It was already asked here:

红条在关闭UIImagePickerController时已注意到

我在关闭时还注意到了红色的状态栏,可以通过以下方法解决:

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

您应该在.plist中将基于视图控制器的状态栏外观"值设置为YES

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

这篇关于关闭时的UIImagePickerController混乱的标签栏框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-14 19:49