Adjusting the UiTableview hight in IB so the the table its able to scroll all the rows - ios

I have a UITableView that is cutting off the last row and a half. I assume this is due to the face that I am using a navigation controller. What I can't figure out is how to adjust the height of the TableView so that it works on both iPhone 4 and 5's. If I adjust the height in IB to fit the iPhone 4, I have a large gap on the bottom of the iPhone 5. I would think there is some automatic way of doing this, but nothing I am trying seems to be working.

Auto Layout - Official Guide...
Also, if you're using a UITableViewController on the storyboard, this will solve your problem (with or without navigation controller, which is unrelated). If you're using a UITableView on a regular UIViewController, however, the best answer is auto-layout.

Related

Width and height not adjusting with Xcode Auto Layout

I have created an interface for my app in Storyboard under the Any x Any layout setup, when I run my app the layout is still sized for the square Any x Any and not the phone screen. I want the app to adjust to all sizes and not use a set layout for set screen sizes. How can I do this?
Here are pictures to show my design, and the outcome of running the app.
Storyboard View
Simulator View
The table view is also cut off here
If your ViewController is subclass of UIViewController then add leading, trailing ,top and bottom constraints to UITableView, and contains to your custom navigation bar. or If its subclass of UITableViewController. No need to add any constraints. Just embed your TableViewController into NavigationController.
Hope this will help you
what exactly are you trying to achieve? Your tableview to be entirely on the screen, so not scrollable?
If so, then you should override the layout of your tableview and its corresponding cells. As those cells (and the number of them) define the height of your tableview.
From what I can see it appears that you have manually added a UINavigationBar. I personally find it much easier to embed your view controller into a navigation controller. This will provide you with a navigation bar that will automatically resize depending on the hardware, or size class, of the device. To embed it go to: Editor -> Embed in -> Navigation Controller.
Your TableView seems to be fully in the screen as well? If you have layout issues with your cells not adjusting then I will be more than happy to help you once you clarify what is not quite right.
Hope this helps.
Yep. Been there, done that. Just because something is centered in the Any x Any view in interface builder does not mean it will also be centered e.g. in an iPhone simulator. You always need to make your layout choices explicit with constraints, i.e. in the this case add a "center horizontally in superview" constraint or align the right and left edge with the superview (I really would need to know more about your view controller in interface builder to tell you exactly).
Are you familiar with constraints or should I add some more detail on how to solve this?

iOS8 UITableView and Cell - Autolayout Height - Shift / Vertical offset bug on touch and perform segue

I have an annoying problem with my tableView when i touch a cell which contain an autolayout label (description of the image). The autolayout works well, but, just when i touch the cell before the segue, a cell shifting movement appears (down or up and never the same height).
Don't understand why and this problem is random , I feel it rather happens when a cell is close to appear at the top or bottom.
Here a video of the problem on touch / click on the cell and transition to an another view.
http://youtu.be/kJALa8PhD-U
Image : http://i.stack.imgur.com/uWzDr.png
Reminds something to someone ?
On IOS8 - Swift, Same problem on my iPhone.
Thanks!
Likely what is happening is that because you are using auto layout to get a dynamic height tableviewcell, and iOS is not properly calculating the height of your cells during the segue. Using either the estimatedHeightForRowAtIndexPath delegate callback (if you have varying heights) or the estimatedRowHeight would be my guess at how to fix this.
Doing this should get you two benefits, firstly your views should stop flickering during the segue. Secondly, iOS will not have to look at all of your tableview cells to determine the height of it's scroll indicator (which is good for performance).

iOS8 UITableView won't scroll to footer

The problem might be related to this post iOS 8 Auto cell height - Can't scroll to last row but here the conditions are different.
I'm not using self-sizing, just a typical UITableView with fixed height cells. that you'd want for a Settings screen. However, I do add a footer and few other subviews below the footer of the UITableView. I do update the contentSize properly to take into account those added subviews.
Everything works fine on iPhone4/5 on iOS7 but the UITableView won't scroll all the way to the bottom on iOS8 although I do see the content if I try the hold+scroll trick. Any idea what's happening?
Thanks!

Difference in constraints iOS 7 and iOS 8. Xcode 6 seed

So I have a UIViewController with a UIImageView and a Collection View, as well as a Navigation Bar. This app is only in portrait mode and won't change when rotating.
in iOS 7.1.2 and below, it shows up correctly, like this:
image1 http://imageshack.com/a/img911/4185/koGDtt.jpg
In iOS 8, it shows up incorrectly where the collection view is at the very top of the screen behind the navigation bar, like this:
image2 http://imageshack.com/a/img673/2531/NWYWsn.jpg
I have been trying for a couple days now, varying ways of constraining the collection view and it has always yielded the same results. I have searched SO for an answer that may help me resolve this issue but have not been able to come up with something that worked.
I am generally constraining the top of the collection view to the superview (330), the leading and trailing edges to the edges of the superview (0), and then height/width constraints on the UICollectionView to it's dimensions (320, 80).
I tried making a new UIView in IB, constraining it to the outer edges of the superview, and then constraining the collectionView to this new UIView, but it still did the same thing. I'm at a loss here and really appreciate any help you all can give me.
So I figured this out finally. It was completely unrelated to constraints and was in fact a line of code that displaced the entire UICollectionView in iOS 8.
In the -didSelectItemAtIndexPath method I made a call to update the selected indexPath of the collectionView using this line:
[collectionView reloadItemsAtIndexPaths:indexPaths];
I was also pre-selecting an cell at indexPath 0 in my -viewDidLoad so that the first item of the collection would be highlighted, which caused the -didSelectItemAtIndexPath to be called right away.
For some reason, the reloadItemsAtIndexPaths line would change the view of my entire collectionView to the top of the screen.
I replaced this line with:
[collectionView reloadData];
and now everything works fine as intended.

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.

Resources