views:

70

answers:

1

I have created an iPhone UI programmatically but I just can't figure out how to fit a view so that it doesn't get overlapped by the TabBar. Here's the ownership hierarchy:

- AppDelegate

  • UITabBarController
    • UINavigationController x
      • UITableViewController
        • UIViewController (with XIB)
          • UIScrollViewController (in the same XIB as parent)

The problem is that my TabBar hides a part of my UIScrollView (and my tableviews as well, but that's not important). I tried manipulating the scrollview content size and the view frame size but with no luck.

So far the best I could do was to add a 60px padding on the scrollview's content size like this:

[scrollView setContentSize:CGSizeMake(self.view.frame.size.width, self.view.frame.size.height+60)];

Thanks for your help!

+1  A: 

Sounds like you may have to make sure your scrollView's frame is set properly first. The contentSize will determine the dimensions of the content of the scrollView. In other words how far you can scroll in each direction. Take a look at the scrollView in your nib and make sure the frame is the right size you need to fill.

Jeff
Thank you Jeff, this is indeed what I needed to do:1) Open my nib in IB and the set the view and scrollView frame sizes to whatever I needed to edit the content easily2) Set the UIScrollView content size programmatically with [scrollView setContentSize:self.view.frame.size];3) Set the UIScrollView frame programmatically to the exact dimensions of what the user can actually see (in my case, the height was the iPhone screen height minus the tabBar height and navigationBar height): [scrollView setFrame:CGRectMake(0,0,self.view.frame.size.width, customHeight)];
DavidD