iPhone : TabBar overlaps above UIScrollView - iphone

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!

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.

Related

iPhone: Make UIScrollView from UIView

I have a UIView with labels and textfields and I tested it in the simulator and noticed that I cannot scroll to see the rest of the view, how can I make the view into a UIScrollView and what do I need to do so I can make the view scrollable? I don't want to move labels and stuff or delete the UIView, is there a simple way?
Take a UIScrollView in Xib file outside your view. drag your view into this scrollview. The subviews inside your view remains same. and set the scrollview's contentSize

ScrollView in iPhone interfacebuilder

I have put 14 items in scroll view but it gets stuck after 6 items. I have not put any code, just did all from interface builder (items are arranged vertically). I can see the items below but it jumps to 6 items when I release the touch. It is not that the scroll view is not working, it is just not showing as much I want it to show.
Has any-body got any idea what is happening? any help is appreciated.
You should set the content size of your scrollview.
e.g.
[scrollview setContentSize:CGSizeMake(scrollview.contentSize.width, heigth)];
Where set height that contains all your sub controls in scrollview.
Scrollview content size is not set properly. Use setContentSize: to set the content size of the scrollview
You added the content into scrollview so now you have to make scroll know to what size it shoul scroll and show the content
Do
Set an outlet and then add this code in viewDidLoad
[scrollview setContentSize:CGSizeMake(width, height)];
From Docs
contentSize
The size of the content view.
#property(nonatomic) CGSize contentSize
Discussion
The unit of size is points. The default size is CGSizeZero.
Here is a nice tutorial since you are a beginner .
may be its too late, but here is how i solved it:
put the items in a UIView and stretch that view as much as it need to be stretched.
put that UIView in the scrollview.
put a scroll view in the main uiview, the height and width will be similar to uiview.

Setting static content in a UIScrollView through XIB

I need a UIScrollview to show some static content in my app. I have taken a UIScrollView through XIB and started adding some UIImageViews and textViews in to it. But after coming to the end of the scrollView the view is not exapanding anymore. I need more space so that I can add some more views below. Is there any way in which I can do this (through XIB and not through code).
I struggled a lot to get this done in a more elegant way then the solution described by Csabi.
It's really simple:
In your xib file just add a generic view which is not a subview of your viewController.view (i.e although this view is in your xib file, it is not a part of your viewController's view hierarchy.)
Then select this view and using size inspector set the width and height that suits your need. Add whatever objects you want to this view. Hook up this view to your viewController with an IBOutlet. (Let's call it IBOutlet UIView *myBigView).
in your viewController.view drag a ScrollView and adjust the size of the scroll view as you like. Hook this up to your viewController. (IBOutlet UIScrollView *scrollView)
Now it's super simple:
-(void) viewDidLoad{
[super viewDidLoad];
self.scrollView.contentSize = self.myBigView.bounds.size;
[self.scrollView addSubview:self.myBigView];
}
Yes it is you can define the height of the UIScrollView simply for example height:1800
now you get bigger UIScrollView then your view you can put your objects to scrollview, and if it is filled simply pull it upward and drag and drop other items when you are finished simply pull the scroll view to its position and you have it.
It is simple :)
Hope it helps
Ask if you have any other question

UIScrollView resizes when a UIViewController is pushed in UINavigationController. Why?

When I push a UIViewController within a UINavigationController, the UIScrollView in the view changes dimensions. Now even I am trying to resize the UIScrollView. It wont simply resize. It maintains the framework dimensions. Any idea why this would be happening.
Example:
My NIB has a view which has a scrollview with dimensions (320, 430)
now when I push the UIViewController associated with the view the scrollview still shows dimensions has 320, 430, but is drawn much smaller then 320,430 alt text http://img717.imageshack.us/img717/6554/screenve.png
Any suggestions in this regard.
This was happening because of the autosizing mask property of the view i created programmatically was set. Resetting the flag solved the problem.

Resizing UITableView on RootController

Is it possible to resize the UITableView on the RootController of a nav based app? When RootViewController.xib is opened in IB, there isn't a view. Just the UITableView. Clicking the inspector and then the little yellow ruler, frame height is grayed out. I'm adding a toolbar programmatically to the RootViewController:
[toolbar setFrame:rectArea];
That works fine but the bottom cell in the tableview is partially hidden because the tableview doesn't know about the toolbar.
The easiest way, is to adjust the contentInset (which is inherited from UIScrollView). Resizing by setting the frame can cause crazy drawing bugs in cells.
For example, if you are trying to resize a tableview for the keyboard, do something like this:
tableView.contentInset = UIEdgeInsetsMake(0.0, 0.0, 216.0, 0.0);
tableView.scrollIndicatorInsets = tableView.contentInset;
Hope that helps someone. This way worked best for me.
Yes, but you need to have a ViewController (not a UITableViewController) as the root controller for the nav, and wrap the actual UITableView in the UIViewControllers view.
You can still have the UIViewController conform to the UITableViewDelgate and Datasource protocols, and use all the same methods you have now in your UITableViewController.
P.S. you'll get more responses if you use the plain "iphone" tag.
You could also just set the Content and Scroller inset of the tableview
I encountered a similar issue when attempting to display the detail controller by itself, see: http://vimeo.com/13054813
The issue is that the SplitView controller applies its own transform to the sub-controllers, taking them out of the orientation detection loop, which blows goats and seems incredibly 'hackish' for built-in classes. (The video illustrates what happens when you make the detail view the root view, then add it back to the split view and make the split view root while in landscape; you get double rotation of the detail view.)
Unfortunately I've again run into these transformation issues while attempting to resize a SplitViewController's detail sub-view in response to the keyboard appearing/disappearing. In portrait, all works fine, in landscape it's fscked.
Yes, adjust the contentInset and scrollIndicatorInsets are the convenient way to resize the UITableView.
As the answer of Sam Soffes posted, I succeed resize UITableView in UITableViewController for the bottom UIToolbar.