I'm having trouble adding a UITableView to a UIViewController in Xcode 5 (DP4). When I add the table view and add a cell to the table through Interface Builder Storyboards, the table adds an extra white gap/space above the first cell. This seems to be happening when I embed the view controller in a Navigation Controller.
When I build and run the space is still there so it's not just a quirk in IB.
See the picture below to see what I mean.
https://www.dropbox.com/s/tgqolwmo02h91d6/Screen%20Shot%202013-08-20%20at%2011.52.27.png
This doesn't happen on Xcode 4.6
https://www.dropbox.com/s/8giyj2mjdhcrhy4/Screen%20Shot%202013-08-20%20at%2012.37.06.png
It looks like the Table View can't be the first child of the view controller's view. Drag it down below another view to fix the issue.
If you want more help, you'll need to go on Apple's developer forum (NDA, blah blah blah), but I'd say have a look at your constraints. Keep a backup of your XCode 4 story and upgrade it in XCode 5, you might see what is wrong.
When you add a UITableView to a blank view canvas it adds a 20 pt constraint to the top to account for the status bar. Embedding the UITableView in a navigation controller after this constraint was already set added this padding to the top of the UITableView. I found this constraint in XCode but no matter what I did I couldn't remove it. What I ended up doing was removing the UITableView from the View and then adding it back and the constraint was gone. The UITableView remained the first child of the view so I don't think that's a specific requirement.
Related
I have a static table (UITableViewController) with few cells , its a data entry form basically, when i created this and put all the constraints all was good until i reloaded the project , now all the components are outside of view and entire layout is messed up along with constraints. This has happened twice and i have no idea why this is happening
I deleted entire project and pulled it from repository , but still its same
important thing is this runs fine inside app, shows the correct screen , so looks like this is some Xcode rendering specific issue,also this it not happening with some other screens in project, I have tried deleting tableviewcontroller and adding it thrice but same result.
This TableViewController is linked to a UIViewController which has collectionview upon taping one of the collectionview cell this view gets laucnhed and hence linked though a show segue.
****** edit ***********
Figured it out , this happens especially when i add height and width constraints to the label and textfield
ok here is how i solved the issue ,
I found out that if i add height constraints on controls inside a TableViewCell then it would mess up the design, thus not adding height constraints and instead managing with top and bottom spacing helped. Still not sure why this is happening to only certain TableViewController and not all.
I am working on a Swift iOS8/9 project and using Xcode 7, with storyboard / autolayout, etc. (For completeness: I started at the beginning on the year on older versions of Xcode, etc.)
I have a a UINavigationController hierarchy and some View Controllers contain a single UIView which contain a single child, a UITableView. (I am choosing not to use UITableViewController, so suffice to say ... it is not an option.)
The problem: The tableview starts 64 pixels (status plus nav height) too low:
Now: I've had things working for some of my UIViewControllers containing a UICollectionView within a UIView but I achieved it (after lots of poking / prodding, and a while back) by a top alignment constraint from the top of the UICollectionView to the top of the Top Layout Guide. (Looking through my storyboard I some alignments and some vertical distances, but all to top of Top Layout Guide.)
I am looking for help understanding if I can do what I want, if the approach of constraining the top of the tableview to the top of the layout guide is correct, or if there is a better way.
Unfortunately, I cannot seem to repeat this (perhaps 'cos I've forgotten some key press combination jujitsu, or new Xcode, or collection != table, or something in my view hierarchy. (I've checked all segues are adaptive push, I've even deleted/re-built this VC since I had one model segue, just in case it was confused that this VC isn't in a navigation view controller hierarchy.)
If I control/drag to connect or select the two to align:
this is what I am offered - note no "align to top":
Note: Here are the table settings that (to my understanding) should be adjusting edge inset and scroll offsets correctly, and do appear to ('cos it is the only child of the top view, per documentation.)
Here are the frames after view did layout subviews:
The approach that I ended up using came to me when I spoke to #ProgrammingBonn and mentioned the frames. I saw that the primary UIView was position as I wanted, and so it (finally) dawned on me to align the top of UITableView to the top of the UIView.
(I suspect that much as I was building my own ViewController and not relying upon UITableViewController I had an over inflated view of this particular view within the hierarchy. It was a subview not a primary view, despite occupying all the screen real-estate.)
So, to be clear:
I selected the UITableView, then command/selected the UIView (the main one, and it's parent) and then used the "align" tool to top align those two.
Try unchecking the "Adjust Scroll View Insets" option.
I am not sure whether this will fix your problem but have you tried playing around with viewController.edgesForExtendedLayout?
See more info here:
Explaining difference between automaticallyAdjustsScrollViewInsets, extendedLayoutIncludesOpaqueBars, edgesForExtendedLayout in iOS7
I have a UIPageViewController that shows 3 child view controllers. The controller is working fine, but on the first page he shows a few vertical columns of pixels from the second page (you can see the grey of the search bar and a selected cell). This behavior is not occurring between the 2nd and 3rd child VC.
First VC (see the overlap on the right side)
Second VC (no overlap on the left or right from the 1st or 3rd)
Third VC:
The code relevant to this issue is here: http://pastebin.com/Dn7nkKHj
Could this be an auto-layout issue? Or an issue with the UIPageViewController. And how can I avoid/correct it?
I don't think that this is an auto layout issue because if there is some issue due to auto layout it will create same effect with second and third view controllers also. Can you please share our storyboard so that I can look check whether there is some auto layout issue.
This is a bug, filed in bug reporter as bug n° 22947439
There is a workaround however:
In the above screenshot, I have circled with a red dashed line the setting you need to un-check. After this, you need to make sure the “constant” value is not -20, but 0. Repeat this for all the leading and trailing constraints of your table views.
I've seen similar questions about custom transitions(iOS7 Custom ViewController transition and Top Layout Guide and Navigation controller top layout guide not honored with custom transition), but I have problem even with regular push. I'm using latest Xcode available now (Version 5.1.1 (5B1008)).
Here is my storyboard:
Problem occurs in 3rd VC
Here is 3rd VC settings:
My 3rd controller's layout is follows:
UIView
UIScrollView
InnerUIView
Other views
I've tried two different ways to create a layout:
Ignore top layout guide (it has y = 64 because of nav bar)
I pinned scrollview's top to container (ignoring topLayoutGuide), manually set height of inner view and pinned its top to scrollView. It gave me the following result:
Looks fine, but why do I need top layout guide then?
Use topLayout guide
ScrollView's top is pinned to topLayoutGuide.
As you can see, top button moved down and view looks strange.
What is the right way of creating such layouts?
I had the same problem and spent hours pulling my hair out.
My container view inside scrollview had weird top offset despite the fact that it had top constraint set.
The workaround I've found - you have to uncheck Adjust Scroll View Insets in your controller layout options
that way content view (in my case) stays pinned to scrollview's top.
Unfortunately I couldn't find any reasonable explanation of this behaviour.
In my case, Xcode 7 and 8, I had to uncheck the 'Adjust Scroll View Insets' for the Views in my Navigation View Controller. And yes, it wasted too much time before I figured this out.
EDIT: Apple has found out that we have found a solution, so they managed to break this again in XCode 9 and 10, to keep us developers pulling our hair. Haven't found a solution yet.
This may be me being stupid, but I'll ask the question anyway (at the risk of being down voted to death).
I have a UITableView in a view controller in story board. The size is width=213, height=559. Looks fine in storyboard.
In the ipad simulator (version 6.1) the table has width ~276 and height 559.
I have added no code at all (created a new view controller, dragged in a table, sized it to width213, added a button of width 213 just to have a place marker). Added a button elsewhere in my app that does a model to the new view controller.
I'm using xcode version 4.6.1
Any thoughts?
It seems I don't have any tableviews laid out in a storyboard, but since XCode 4.6.~ I have quite a bit of trouble with the "Autolayout" feature. I would try selecting the problematic table view, then under the file inspector, unselect "Use Autolayout" It seems ON by default now, and causes my .xib's and storyboards not to work as I would expect.