旋转后视图不适合屏幕
虽然在模拟器中问题不存在,但在自动旋转到横向后我遇到了视图问题。当我以纵向加载应用程序时,一切正常,但当我旋转设备(iPod touch 第一代 3.1.3)以横向显示时,结果是这样的: http://imageshack.us/photo/my-images/155/img0021n.png/ 。 如果我切换到第二个视图(“Riepilogo”,即表格视图),然后返回第一个视图,则视图完全适合横向,但如果我再次旋转到纵向,问题与上面相同。
下面是shouldAutorotateToInterfaceOrientation的代码:
- (BOOL)shouldAutorotateToInterfaceOrientation(UIInterfaceOrientation)interfaceOrientation{
if (interfaceOrientation==UIInterfaceOrientationLandscapeLeft || interfaceOrientation==UIInterfaceOrientationLandscapeRight) {
[self.scrollView setContentSize: CGSizeMake(480,416)];
} else {
[self.scrollView setContentSize: CGSizeMake(320, 416)];
}
return (interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight); }
PS视图是UIScrollView的实例
while in the simulator the problem don't subsist, i've a problem with a view after auto rotating to landscape orientation. When I load the app in portrait, all works fine, but when i rotate the device (iPod touch 1st gen. 3.1.3) to landscape the result is this: http://imageshack.us/photo/my-images/155/img0021n.png/ .
If i switch to the second view ("Riepilogo" i.e. a table view) and then back to the first, the view fit perfectly in landscape, but if I rotate again to the portrait orientation, the problem is the same as above.
Here is the code of shouldAutorotateToInterfaceOrientation:
- (BOOL)shouldAutorotateToInterfaceOrientation(UIInterfaceOrientation)interfaceOrientation{
if (interfaceOrientation==UIInterfaceOrientationLandscapeLeft || interfaceOrientation==UIInterfaceOrientationLandscapeRight) {
[self.scrollView setContentSize: CGSizeMake(480,416)];
} else {
[self.scrollView setContentSize: CGSizeMake(320, 416)];
}
return (interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight); }
P.S. The view is an instance of UIScrollView
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
调整滚动视图的大小不会调整其内容的大小。
Resizing a scrollview doesn't resize its contents.