After much research, I think I found the problem to my application, but I cannot find the solution to it.
经过大量的研究,我认为我的应用程序发现了问题,但我无法找到解决方案。
In my project, as shown in the screenshot, I have a UITabBarController
as the initial viewcontroller. UINavigationController
will "show (push)" to display UIViewController
. Inside my UIViewController
, I will call UIImagePickerController
which is set by XCode to present on "Modal".
在我的项目中,如截图所示,我有一个UITabBarController作为初始viewcontroller。 UINavigationController将“show(push)”显示UIViewController。在我的UIViewController中,我将调用UIImagePickerController,它由XCode设置为“Modal”。
The issue comes in, when I dismiss the UIImagePickerController
, the UITabBar items disappears. I know it has got to do with dismissing the modal, but I can't find solution to it.
问题出现了,当我解雇UIImagePickerController时,UITabBar项目消失了。我知道它与解雇模态有关,但我无法找到它的解决方案。
My codes as follow:
我的代码如下:
On click of a button inside UIViewController
单击UIViewController内的按钮
@IBAction func chooseLibrary(sender: AnyObject) {
let picker = UIImagePickerController()
picker.delegate = self
picker.sourceType = .PhotoLibrary
picker.allowsEditing = true
self.navigationController?.presentViewController(picker, animated: true, completion: nil)
}
On click of "Cancel" inside UIImagePickerController
单击UIImagePickerController中的“取消”
func imagePickerControllerDidCancel(picker: UIImagePickerController) {
self.navigationController?.dismissViewControllerAnimated(true, completion: nil)
}
2 个解决方案
#1
0
Try this:
@IBAction func chooseLibrary(sender: AnyObject) {
let picker = UIImagePickerController()
picker.delegate = self
picker.sourceType = .PhotoLibrary
picker.allowsEditing = true
self.navigationController?.pushViewController(picker, animated: true)
}
func imagePickerControllerDidCancel(picker: UIImagePickerController) {
self.navigationController?.popViewControllerAnimated(true)
}
#2
0
Set viewController.hidesBottomBarWhenPushed = NO; for all the controllers in which you want to show your tab bar. This flag must be set when you push / present your view controller. Hope this will solve your problem.
设置viewController.hidesBottomBarWhenPushed = NO;对于要在其中显示标签栏的所有控制器。按/显示视图控制器时必须设置此标志。希望这能解决你的问题。
#1
0
Try this:
@IBAction func chooseLibrary(sender: AnyObject) {
let picker = UIImagePickerController()
picker.delegate = self
picker.sourceType = .PhotoLibrary
picker.allowsEditing = true
self.navigationController?.pushViewController(picker, animated: true)
}
func imagePickerControllerDidCancel(picker: UIImagePickerController) {
self.navigationController?.popViewControllerAnimated(true)
}
#2
0
Set viewController.hidesBottomBarWhenPushed = NO; for all the controllers in which you want to show your tab bar. This flag must be set when you push / present your view controller. Hope this will solve your problem.
设置viewController.hidesBottomBarWhenPushed = NO;对于要在其中显示标签栏的所有控制器。按/显示视图控制器时必须设置此标志。希望这能解决你的问题。