【发布时间】:2015-01-30 10:44:40
【问题描述】:
在我的应用程序中,您可以点击UIButton,然后弹出一个弹出框并显示用户的照片库。
我正在使用此代码来实现这一点:
let picker = UIImagePickerController()
picker.allowsEditing = false
picker.sourceType = .PhotoLibrary
picker.modalPresentationStyle = .Popover
self.presentViewController(picker, animated: true, completion: nil)
picker.popoverPresentationController?.sourceRect = CGRectMake(600,180,0,0)
picker.popoverPresentationController?.sourceView = self.view
上面的代码运行良好,并且确实向用户显示了弹出框。但是,它也会显示一个白色状态栏。
我尝试了多种方式隐藏状态栏:
UIApplication.sharedApplication().statusBarHidden = true
我确保 info.plist 文件中的 String 设置为 NO: View controller-based status bar appearance。
我的课堂上也有这段代码:
override func prefersStatusBarHidden() -> Bool {
return true
}
UIViewController 属性检查器如下所示:
不幸的是,弹出框仍然显示状态栏。为什么?我该如何解决?
【问题讨论】: