【问题标题】:UIImagePickerController messing tabbar frame when dismissingUIImagePickerController 关闭时弄乱标签栏框架
【发布时间】:2015-01-21 19:21:42
【问题描述】:

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

SourceType 相机
MediaType kUTTypeMovie

呈现 UIImagePickerController 没有问题,但是当关闭 TabBar 时,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

【问题讨论】:

    标签: ios iphone swift uitabbarcontroller uiimagepickercontroller


    【解决方案1】:

    这里已经问过了:

    Redbar Noticed when dismissing UIImagePickerController

    我还注意到关闭时的红色状态栏,使用此解决:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-02-15
      • 1970-01-01
      相关资源
      最近更新 更多