UIPresentationController - presentation view size?

14 views
Skip to first unread message

Max Farrar

unread,
Mar 25, 2015, 2:28:25 PM3/25/15
to swift-l...@googlegroups.com

I'm using a UIPresentationController, but I can't sort out how to get it showing the way I want it to.

I'm editing the frameOfPresentedViewInContainerView() function, and I need to be returning the frame (a CGRect) to display my content in.

The tutorial I followed uses CGRectInsert(self.containerView.bounds, 50, 50), which makes the window centered with the borders brought in 50px. If I return self.containerView.boundsjust as itself, the view takes up the whole screen.

I'd like the overlaying view to be the width of the parent view (so, self.containerView.bounds.width), but I want the height to be the size needed to show the content of the new view without cutting anything off.

I tried a CGRect at (0,0) with width and height from self.preferredContentSize, but it's not returning sizes that work.. What can I do?

I tried frame = CGRect(x:0, y: self.containerView.bounds.height/2, width: self.containerView.bounds.width, height: self.containerView.bounds.height/2) just as a test (but that's just making the view half the size of the parent view), but when I rotate the screen, suddenly the new view is almost off screen..

Reply all
Reply to author
Forward
0 new messages