开发者

UIScrollView height adjusts from IB

开发者 https://www.devze.com 2023-03-16 01:00 出处:网络
I\'ve created a UIScrollView in Interface Builder which takes up the entire screen of the iPad (0, 0, 1024, 768)

I've created a UIScrollView in Interface Builder which takes up the entire screen of the iPad (0, 0, 1024, 768)

However - when running the app, the scrollView is only displaying on the screen at (0, 0, 1024, 440). The 440 is an estimate, but it is not extending all the way down to fill the screen as it should.

I've done this same thing in other apps and have not encountered this issue. I've run "Clean" on the project and I've tried deleting the scrollView and recreating it and still the same issue occurs.

I even tried to programmatically reinforce what's in Interface Builder but still it showed up the same way.

CGRect scrollFrame = CGRectMake(0, 0, 1024, 768);
[scrollView setFrame:scrollFrame];

If you have any idea why this may be happening, your help would be GREATLY appreciated.

* UPDATE * After some more research, there is something wrong with the view controller. That area at the bottom where the scrollView isn't showing is totally not accessible. If I put a button toward the bottom of the screen, I can't click that button. If it's up in the top half of the screen I can click it just fine.

Also, the scrollview isn't really starting at 0, 0. Where it start开发者_StackOverflow社区s it is missing the top part of the content. So it seems like the scrollView DOES have the height of 768, but is starting at -320 so that the top of it is off the top of the screen and the bottom of it ends before the bottom of the screen.


The issue seems to have been that the app thought it was in Portrait mode even though I had the .xib in Landscape mode.

Fixed it with this little trick in the viewDidLoad of the mainProjectViewController:

CGRect landFrame = self.view.frame;
landFrame.size.width = self.view.frame.size.height;
landFrame.size.height = self.view.frame.size.width;
self.view.frame = landFrame;


Actually, viewing it in landscape mode is just a convenience for you to see what happens if you rotate the device. Launching in landscape mode can be problematic. See this question and its answers for some excellent info.

0

精彩评论

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

关注公众号