开发者

Working with Landscape Views designed with interface builder

I'm trying to understand something that , by googling around, seems like a bug in the iPhone sdk, but maybe its just something hidden im not sure of.

I designed a new view in Interface Builder, in landscape mode. It looks like this:

Working with Landscape Views designed with interface builder

But when i load it in from one of my other views, even though it is landscape, all the content doesnt look as it looks inside interface builder, it looks like this:

Working with Landscape Views designed with interface builder

I found some code in google that helped to sor开发者_如何转开发t-of fix this issue, but the solution isn't perfect , and honestly its just kind of an ugly workaround, the code is (in viewDidLoad):

// First rotate the screen:
[UIApplication sharedApplication].statusBarOrientation = UIInterfaceOrientationLandscapeRight;

// Then rotate the view and re-align it:
CGAffineTransform landscapeTransform = CGAffineTransformMakeRotation( 1.570796327 ); // 90 degrees in radian
[self.view setTransform:landscapeTransform];

This code actually almost completely solves the problem, but still doesn't look exactly like my XIB:

Working with Landscape Views designed with interface builder

I'd love to know if any of you creative minds have a better solution for this, and if not, if you can help me change the code above to maybe come closer to the "original" design in the xib file.

Thanks in advance! :)

Shai.


The reason your view is being pushed up is because the it's starting in the left top corner behind the status bar. Try adding this after the rotation:

landscapeTransform = CGAffineTransformMakeTranslation(0, 20);
[self.view setTransform:landscapeTransform];
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜