我有一个Tab Bar Controller,它提供了一个NavigationController。在其中一个ViewControllers中,我推动了这一点,我添加了imagePickerController来选择一张照片。当我取消或选择图片时,标签栏消失...我试图找到答案,但我找不到引用我特定问题的答案。
这是我的图像选择器方法
@IBAction func attachImageBtnTapped(sender: AnyObject) {
if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.PhotoLibrary){
imagePicker.sourceType = UIImagePickerControllerSourceType.PhotoLibrary
imagePicker.modalPresentationStyle = UIModalPresentationStyle.CurrentContext
self.presentViewController(imagePicker, animated: true, completion: nil)
}
}
func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) {
attachImageBtn.backgroundColor = UIColor.greenColor()
dismissViewControllerAnimated(true, completion: nil)
}
我该如何避免这种情况?我试着看看我是否将tabar设置为隐藏在viewWillAppear中,但是没有。
任何想法,任何帮助都将非常感谢!
答案 0 :(得分:5)
我发现错误,我需要提供imagePicker控制器'OverCurrentContext'。
@IBAction func attachImageBtnTapped(sender: AnyObject) {
if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.PhotoLibrary){
imagePicker.sourceType = UIImagePickerControllerSourceType.PhotoLibrary
imagePicker.modalPresentationStyle = UIModalPresentationStyle.OverCurrentContext
self.presentViewController(imagePicker, animated: true, completion: nil)
}
}