iOS Swift : SlidingMenuView wrong Position after presenting imagePicker

佐手、 提交于 2020-01-06 19:15:29

问题


I am using PageMenu in my project within a TabBar Controller and a Navigation Controller. When I initialize the "Scrolling menu" I use this to display it under the statusBar and the navigation bar :

pageMenu = CAPSPageMenu(viewControllers: controllerArray, frame: CGRectMake(0, UIApplication.sharedApplication().statusBarFrame.size.height + self.navigationController!.navigationBar.frame.height, self.view.frame.width, self.view.frame.height), options: parameters)

This solution is working perfectly and display my menu exactly where I want ! Then I present an image picker view inside one of the scrolling view. After dismissing it, the menu goes back to the initial place (under the navigation bar)...

Any solution to avoid this issue ? (If you need more detail I can provide more code)

P.S. I'm not a native English speaker so I hope my question is understandable :)


回答1:


Added the viewcontroller "pageMenu" as a child of the parent controller and the problem was solved




回答2:


It's in Obj-C, but Swift is the same I think. In parent view controller, add pageMenu as child VC:

[self addChildViewController:_pageMenu];

In child VC, call picker by this:

UIViewController*vc=self.parentViewController.parentViewController;
[vc presentViewController:imagePickerController
animated:YES
completion:nil];



回答3:


the problem is pageMenu is add in viewDidLoad, and here view hasn't correct measures. Create a container view on storyboard and add PageMenu in container. Work for me, although it may not be good practice



来源:https://stackoverflow.com/questions/29519570/ios-swift-slidingmenuview-wrong-position-after-presenting-imagepicker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!