iOS Swift : SlidingMenuView wrong Position after p

2019-09-03 10:05发布

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 :)

3条回答
老娘就宠你
2楼-- · 2019-09-03 10:26

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

查看更多
我命由我不由天
3楼-- · 2019-09-03 10:40

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

查看更多
Animai°情兽
4楼-- · 2019-09-03 10:42

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];
查看更多
登录 后发表回答