I'm trying to place a tableView in a viewController, but im not able to constraint properly the tableView, i'm doing the usual things, i'm sticking the leading, trailing and bottom constraints to superview, and some space to the top superview. But as shown in the preview, table view does not look to be constrained, the effect that it brings for me is that when i put elements into content view, they extend along the right side i can not see them for small devices. Does anyone know what could be happening?
Thanks in advance!
StoryBoard Tree
After spending long time checking what happened i figured out that there is a Xcode fail on it, i run it in simulators and real devices and it works perfect, the bad thing is that everything i inserted into that view does not look as it should in the preview, but again, in simulator everything works fine. So, preview is not always as trusty as i expected and now i know it
Related
I want to believe this is a simulator bug, but, can somebody please explain what is going on?
Im running a simple View on my storyboard: (as you can see, the view with green background is my superview). The thing is when I run my app on a simulator (sometimes, not always) my superview doesn't get scaled and I get a black screen!! My view has checked true the Use Autolayout field, cause some things inside need to have constraints.
I can't give constraints to my view because, it's the superview
And yes, I have debugged with the UI and this is the thing, my superview is not resizing.
Okay I solved, for sure is a bug of Xcode. For me was very strange, so, I decided to delete my View Controller and add all my elements again.
For some reason, no matter what I do, when I create a static tableview inside a UITableViewController, put content into the cells and run the simulator the right half of the screen is always cut off and I don't know why. Ive tried making new projects and remaking the storyboard but nothings working.
Here's what it looks like when I run the app
heres what the storyboard looks like.
I have content set to static cells
Anyone run into this problem or know how to fix it via storyboard (or programmatically but not preferred)?
Update:
Here are some more pictures of what another project looks like when I run it:
and here's what the storyboard looks like
You need to give constraints to your right button...
For that select your button and pin its edges to right, top, bottom and give width constraint like below
and here is autolayout tutorial link .. you can check that
I see the problem in giving constraints to the table not for the button.
Try giving constraints to the table like "leading space to superview,trailing space to superview,top space and bottom space to superview
Edit:
The above solution given by me might fix for tableview inside UIViewcontroller.
I have a container in my UIControlView.
This is the relevant part of Storyboard. The starting view is a TabBarController, that has a TableView (named _Constructed_) in its second tab. The Table is embedded in NavigationController. When user taps at a cell in this Table, he's taken (with a Show segue) to a GameDetailViewController, that has two containers - the upper one is PageView and the bottom one is TableView.
The issue appears in this TableView. Even though I have constraints set up (width is the same superview's, height is from bottom tabBar to the upper Container, which has fixed height and width), both upper and bottom sides are kinda pushed in a way.
I managed to fix this issue by merely restarting XCode and reopening the project a few times. Maybe it's some kind of a bug, I haven't changed my code in any way and it just started working.
I suggest you need to pay attention to the Size Classes you used. When you reopen your Xcode, it directs you back AnyW, AnyH. It might change the fixed size under some scenario. Also, make sure that you are testing using the same simulator.
I had the same problem.
Im not sure, but you can replace the header from the tableView and it would work right.
tableView.tableHeaderView = myPageView
If it's not the case you should manage the contentInset and contentOffset by yourself for your header and for the list.
As already mentioned in the title, i got a little problem with a ScrollView and Autolayout in my Storyboad.
I have already made a view with an UIScrollView and it works as expected. But I am struggling since weeks with a different view.
I remade the view several times but I dont know what im doing wrong.
The problem is that I can only scroll horizontally and not vertically as usual.
I have also tried copying the old view and changing the content but that hasnt worked either.
The most strange thing, is that the preview of the view looks different as it does in the simulator or on my phone.
Here are a few Screenshots:
Storyboard:
(left: document outline | middle: storyboard | right: preview)
CLICK
Simulator:
(As you can see i can only scroll horizontally)
Thanks in advance for your help (:
You have to connect the elements in the ScrollView with constraints vertically, so the ScrollView knows how wide it's inside is.
I hate iOS scroll views with auto layout, they are driving me crazy!:-D
I have found a method which works perfectly on iOS 7 to use scroll views:
I put the scroll view directly in the main view, attaching the scroll view to the edges of the super view(top,bottom leading and trailing space equals to 0).
Then I put a UIView into the scroll view attached to the edges of the scroll view, (top,bottom leading and trailing space equals to 0).
Then I set the height constraint of the most internal view, I link it at my ViewController class, and I modify its value programmatically.
Or, if the view it's 'static' I put every component using the storyboard into the internal UIView, starting with the one at the Top attached to the top of the super view, the one under, attached with the constraint 'Vertical Spacing' referred to the one over him..and so on... Until the last, which is also attached to the bottom of the UIView..
Everything works fine in iOS 7, it's perfect, but iOS 6 is messing around with the constraint.
When I first launch the view everything is perfect, but it seems to recalculate the constraints even on the didappear(and in a bad way), in fact, if I leave my view while it's scrolled down, when I come back to it(let's say we are in a navigation controller) , is like it's everything 'moved up' and the components at the top are hidden.
Is there a way to make scroll views work in both iOS 6 and iOS 7, I'n thinking at two storyboards as the only solution, please tell me there is another way... :-)
thanks everyone, I post two images explaining my problem, taken from the top of the screen:
Well uncheck use AutoLayout in file inspector and try.