当解雇时,UIImagePickerController弄乱tabbar框架

时间:2015-01-21 19:21:43

标签: ios iphone swift uitabbarcontroller uiimagepickercontroller

我试图在UITabBarController内的UIViewController中显示UIImagePickerController

SourceType相机
MediaType kUTTypeMovie

呈现UIImagePickerController没有问题,但是当被解雇时,TabBar向下移动了一半的高度,有时只会发生......其他它完全无视。

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

它也显示此错误:

  

“快照未渲染的视图会导致空白   快照。确保您的视图至少在之前呈现过一次   屏幕更新后的快照或快照。“

以下是应用和错误外观的视频:

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

1 个答案:

答案 0 :(得分:3)

这里已经有人问过:

Redbar Noticed when dismissing UIImagePickerController

我也注意到解雇时的红色状态栏,使用此解决:

你应该设置"查看基于控制器的状态栏外观" .plist中的值为YES