UITableView creeps underneath button - ios

I created a UITableView with a button underneath. When I run the app on iPad in portrait, the UITableView creeps under the button, like so:
I am clueless as to why this happens. It only happens on iPad in portrait, so I don't think it's a Xib problem.
I would very much appreciate any help with this problem.

You may need to set the UITableView's frame manually when the iPad in portrait as the UITableView may be autoresizing with traits such as sticking to the button of the screen like below. You can play around with the resize options of both the UITableView and UIButton to get this right.
To set the frame manually, set a CGRect to the frame of the element.
tableView.frame = CGRectMake(self.view.frame.origin.x,self.view.frame.origin.y,self.view.frame.size.width,self.view.frame.size.height - uploadButton.frame.size.height);
In this example, uploadButton is the UIButton at the bottom and you are resizing tableView to fill the screen except to the uploadButton at the bottom.

It looks like your tableView's content is not clipping to the bounds of the frame. Try setting clipsToBounds to YES for the tableView.

You probably need to add an autolayout contraint to keep the bottom edge of the table view and the top edge of the button a certain distance apart.

Related

UIView at bottom UIScrollView does not appear

I'm trying to get an UIScrollView working with my Storyboard. It works but the UIView at the bottom that I use with a gesture tap for getting back is not showing. How can this be?
So everything works expect that. This are the things that I did:
Set freeform in Storyboard
Disable auto layout for the Storyboard nib
Changed the freeform dimensions to X:320 Y:800
Dragged some labels and stuff in the Scrollview
Created an outlet for the ScrollView
Enabled scroll programmatically
Enabled Contentsize CGMakeSize() programmatically;
So I normally did everything, why isn't my UIView showing up at Y:750. The only thing I do with the UIView is setting the Background/CornerRadius.
It would be if your UIView is no included in the calculation for the content size. Other than that I cannot see anything obvious.

iOS 7.1 Why is my UIScrollView scrolling away on showing keyboard?

I have a UIScrollView designed with IB.
UIView
UIScrollView
UIView
UITextField
UIButton
...
If I tap on the text field the view scrolls away towards the upper left corner of the screen before the keyboard is appearing. The space above the keyboards remains empty. I can scroll back the view if I drag in this empty space.
I have googled around, but found only postings where users want to scroll UIScrollView. I want the view to stay where it is.
Thanks in advance for any suggestions.
Here's what happened.
You designed the whole thing in Interface Builder.
The scroll view was not scrolling, so you set its contentSize in code to the size of the scroll view's primary subview (what I like to call the content view).
The scroll view was still not scrolling, so you munged the content insets - and this caused the problem that brought you here.
Your mistake was (3). Instead, you should have thought more about (2), i.e., why isn't my scroll view scrolling even though I have given it a nice big content size?
The answer is that, in a storyboard or xib that has auto layout turned on, that's not what you do. What you do is use constraints from the content view to its superview (the scroll view), on all four sides. Set the constant for all four constraints to zero. This causes the content size to match the size of the content view, automatically.

Is it possible set width of UITableView or cells on iPad

Since it's not possible to "hook onto" this and get an answer, and none of the answers do it, I thought I'd ask if anyone ever succeeded in doing it and if so, how.
I've created a New File, selected subclass UITableViewController with XIB, and everything works fine. I can set the height of everything (with delegate methods), but not the frame of anything.
Right now the table is as wide as the iPad and it looks kinda corny with the short titles in each cell - and there is nothing in IB that changes the stretching or layout.
I'd be happy with any solution that causes the cells to shrink horizontally - like margins. I tried scrollview insets in IB, but they only add to the size of the scrollview so it gets bigger than the screen.
I think that you want to subclass UViewController and add a UITableView to it, and make it the size you want in IB.

UITableView rotation issue

I have UIViewController with a UIView with UITableView inside.
All works fine in Landscape mode but when the device is rotated to Portrait, bottom half of UITableView is not accessible (can't even select any row in the bottom half or make table scroll). All rows are displayed correctly.
I am re-framing and repositioning UIView and UITableView on rotation.
Any ideas how to solve this problem?
You should adjust the autosizing in Interface Builder or in code.
I think the UITableView's height is still same with the value in Landscape mode after you rotate device to Portrait.
You can identify it by NSlog your UITableView's CGRect
NSlog(#"frame:%#",[NSStringFromCGRect(UITableView's CGRect)]);

iPhone + resize UITableView

I have a view in which I have UITableView (grouped style). In the Interface builder, I am resizing the UITableView so that it looks like a small portion in center of the screen.
But when I run the application, UITableView takes up the whole area of screen and does not look like the small portion in center of screen (which I had set in Interface builder).
I tried to resize the tableView programmatically in the viewDidLoad method as tableView.frame = CGRectMake (0.0,0.0,100.0,100.0), but still the tableView occupies the whole area of screen.
Please help.
Regards,
Pratik
Sounds like your table view's got autoresized. Try to fiddle with the autoresizing settings.
If your table view is the main view then it will automatically fill the whole view controller's space regardless of the autoresizing settings. In that case, make an empty UIView as the root view and put the UITableView as a subview of it.

Resources