我正在尝试在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

最佳答案

这里已经有人问过:

Redbar Noticed when dismissing UIImagePickerController

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

您应该在.plist中将“基于View Controller的状态栏外观”值设置为YES

10-07 14:11