UIPopoverController Anchor Position

依然范特西╮ 提交于 2019-12-11 06:38:37

问题


I have a UIPopOverController for which the content controller is a UINavigationController. I'm resizing the popover size according to the content size of the controller pushed/popped into it. Initally i'm presenting the popover by using the method presentPopoverFromRect:inView:permittedArrowDirections:animated:. The anchor position is pointing at the center of the rect which i passed as an argument. If i push a controller(whose content size is small) into the navigationController , the popover shrinks from the bottom and moves above the rect which i mentioned earlier.

I tried to present the popover everytime(for push/pop) , anchor position remains @ same point But the animation gets affected , doesnt looks good.

what needs to be done to make the anchor position remains same irrespective of the change in popover size variation ?


回答1:


I've encountered the same issue and it seems that calling the presentPopoverFromRect method again will keep the anchor at the same position

e.g.

[self.myPopOver presentPopoverFromRect:rectOrigin inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:NO];

Hope it works in your case as well




回答2:


Change frame after presenting UIPopoverController:

 [popupController presentPopoverFromRect:btn.frame inView:self.view permittedArrowDirections:0 animated:YES];

CGRect popupFrame = popupController.contentViewController.view.superview.superview.superview.frame;
popupFrame.origin.y = btn.frame.origin.y + btn.frame.size.height+75;

popupController.contentViewController.view.superview.superview.superview.frame = popupFrame;


来源:https://stackoverflow.com/questions/5481653/uipopovercontroller-anchor-position

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