开发者

Have Interface Builder layout my content in a SplitViewControllers DetailView

I was mocking about with Interface Builder and the DetailView of a SplitViewController. I have a UIImageVIew of size 700px by 700px in the detailView and nothing else, I would like it to always position itself in the center. Because it is 700x700 it should fit in both portrait and landscape. However, there is also a UIToolBar governing the top 44 pixels. If I use IB and set the UIImageViews contentMode to center and the detailViews contentMode to center, the UIImageView is positioned so that it covers a few pixels of the toolbar. (but in the center non the less)

I have tried anchoring the UIImageView to the bottom, but it still positions itself in the center and the layout still covers the toolbar.

How would I go开发者_JAVA百科 about doing the layout as "UIImageView:Deduct the space the toolbar takes up and position your self in the center of the remaining view" ?

Hope someone can help, the IB layout engine is a bit heavy to figure out by trial and error:)

Thank you in advance.


Add a UIView that goes from the bottom of the toolbar to the bottom of the entire view and stretches completely left to right. Set its Struts and Springs (cmd-3) so that it resizes vertically and horizontally and is attached to all 4 sides. Then put your UIImageView inside THAT view with all of the same centering you've already done. That will change the UIImageView's frame of reference so when it is trying to be in the center, it'll be in the center of that view which doesn't include the toolbar. Let me know if this makes sense.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜