Scroll bar doesn't reach the end of the tableview - ios

I don't know exactly why, but the scrollbar of my tableview never reaches the end.
This is the middle of the tableview, everything looks fine
But when I reach the end
The scrollbar doesn't reach the end...
I guess my constraints are ok (I'm using autolayout), because besides the scrollbar, the tableview is well displayed.
My view controller is a UIViewController and contains only a UITableView. Here is a screenshot that sums it up :
No constraint is added by code. Do you know how could I debug this?
Thanks in advance
Edit : I have tried to delete and recreate the view controller (by copy and pasting the UITableView) the problem is still here.
Edit2 : If I change the bottom constraint to "Bottom of the view" instead of "Bottom layout guide", this works well.
The problem is that my view doesn't have a correct height, because it is supposed to go under the tabbar.
Any ideas ?

I've fixed the problem by settings the property automaticallyAdjustsScrollViewInsets to NO.
More details could be found here:
https://stackoverflow.com/a/21302259/1295537

What could be happening is you have clipping disabled, and the frame for your tableView isn't the entire height of the view.
Or, you could have contentInsets set, which changes the size of the scroll indicator as well.

For those who the above solutions don't work, try this. It makes no sense tho, but it works (In my case I needed the UITableView to behind other views, so I just added a dummy view)
https://stackoverflow.com/a/23019724/1148910

Instead of using a normal View Controller and dragging in a tableview in a storyboard (which I assume you're doing), have you considered using a Table View Controller? You shouldn't have this problem in that case (I never have). You can easily embed the Table View Controller in the Tab Bar Controller.
Hope this helps!

Related

Overlapping section names in UITableView in Swift

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.

Embedded scrollview in tabbar item using storyboards won't scroll

For my current project I wanted to use storyboards and autolayout instead of coding everything by hand. It has gone well so far, but my design has a section of the app where there is a tab bar and one of those tab needs to show four views. The design is to swipe between the four and so I thought to use a scroll view. After some trial and error I found that embedding a Container View in the tab allowed me to easily set up a scroll view and put a couple of view inside it, carefully aligning them using positioning to put them side by side so that each page is one child view. I'm not sure how that plays with the autolayout, and in fact I have the problem that the scroll view won't scroll past the first page position. I can drag about 1/3 of the second page into view, but it never brings that page entirely in view.
I've checked the content size and offset and all of the view positions and it all seems correct. And when I use Spark Inspector to change the scroll offset to the position of the second view/page, the app shows the right page/view and I can even scroll back to the first page. I'm a bit perplexed as to what is causing it to not scroll properly. I don't have any code to show as this is all done in storyboards, but I am wondering if anyone has any ideas as to what is wrong?
Alternately, does anyone have an idea for how to use autolayout and storyboards to set up swiping four adjacent views in a tab? I suspect there are ways to do it. I can think of ways to do it in code, but I'm trying to avoid doing it that way.
EDIT: I set the scroll view delegate to the view controller around it and checked the values of contentSize on scrollViewWillBeginDragging and scrollViewDidScroll. It is always set to {0,0} even after I force set it on viewDidLoad. So I tried setting it every time scrollViewWillBeginDragging is called, which seems work, but I don't understand why this happens and it doesn't smell right. Is there some autolayout constraint that might account for this? Does something cause contentSize get set to {0,0} during the layout process?
For lack of any other answer, I'll use my unsatisfying solution as an answer in the hopes that helps someone else in the future:
I set the scroll view delegate to the view controller around it and checked the values of contentSize on scrollViewWillBeginDragging and scrollViewDidScroll. It is always set to {0,0} even after I force set it on viewDidLoad. So I tried setting it every time scrollViewWillBeginDragging is called, which seems to work.
I'd love to know why the contentSize is being reset if anyone finds out!

ViewController gets misplaced, when a view size is adjusted

I'm quite new to the Xcode programming. I've added some view controller, labels, buttons and image view to my program, but, when I try to adjust, for example, the size of a label, the view controller that that label is in, gets displaced. I mean, when I try to drag the side of the label to change its size, the view controller moves down, making my label get displaced in the view controller. It is a very weird situation, here you have the screenshot of my project, the view controller misplaced is the one that says "Perfil" on the navigation bar. Every time I try to change one of those light blue views size, the entire view controller changes place. The more I try to change the side the more it will go down.
Sorry for my English, not my native language.
I think the bigger issue is that you are using Table View Cells that are not part of a table view.
Table ViewCells are supposed to be a part of a UITableView and not just stuck in a view.
Using UITableViewCells in this way is what is causing the strange behavior.
If you are trying to make a table, put a UITableView in your view, and then you can customize the table view cells in there.
It you aren't trying to make a table, just use UIView's instead of those UITableViewCells.
I have two ideas that may fix the problem:
First, if you're trying to drag and drop the label but the view controller moves instead, then you might just be grabbing the view controller's background by mistake. When this happened to me, it was because the order of my components in the xib file was wrong. Things are ordered from back to front, and when you click and drag something, you'll just be clicking and dragging whatever's on top. You can try and get past this by clicking the UI element on the left to be sure you select it, then dragging the handles.
It looks like you have things in a reasonable order, so that may not be the culprit at all.
Second, if that doesn't work, select the element you want to edit on the left, then open up the utilities pane on the right. Click the Attributes icon (should be fourth from the left) and look towards the bottom. You should see something like this:
Just manually edit the position and size of your labels there. You should see the change immediately reflected in the display.
Hope this helps!
Setting no autoresize behavior in Interface Builder solves the issue.

Unwanted UITableView Animation

I have a simple UIViewController_A in a Storyboard with a button on it. The button modal segues (page curl) to UIViewController_B which has a container view. The container view then embeds UITableViewController_A. The table displays 1 section containing 3 custom static cells. Each cell has a label on the left and a switch on the right.
When I click on the button, the table is properly displayed where I want it but the cells content, labels and switches, are animated to their positions.
How can I disable this animation? I suspect it is the embedded tableview getting animated while being resized, but am not sure.
I put a simple demo of the problem on github : https://github.com/droussel/UnwantedAnimation
Thanks!
I noticed that only the middle cell animates in. If I increase the cells to 5, the middle 3 animate. This only happens with the partial curl animation -- this looks like a bug in the auto layout system to me. If you turn off auto layout, the problem goes away.
I don't know much about storyboard concept.But I suspect you are starting some animation in button action to have an animation like paging.If so, then just commit(end) your animation after achieved what you want.
[UIView commitAnimations];
Hope it will help you.
In Storyboard segue to that scene/view, open the Attributes inspector, and uncheck ANIMATES. Turns out there is a bug with iOS8 with Partial Curl/Animates.
Hope that helps!

Storyboard UIView cuts off objects when scrolling

Using Storyboards, I have a scrollview with a UIView embeded into it. On that UIView I have some text and a button. The button is down a bit, for this question.
When I scroll in the simulator and on the device, the UIView gets cut off where the button is. (button there to show the cut off)
Above pic is before scrolling.
This pic is showing the scroll UIView and the button embeded into it being cut off.
I have set the Size Inspector to 1000 height.
I have searched on stackoverflow and I have not found an answer as of yet.
Thanks for any help.
It looks like the hierarchy of this particular window is not ordered properly. You need to rearrange your hierarchy. To do this, go to your storyboard, and click on the little button on the bottom left that looks like the play button with a box around it. From there, you can adjust.
I had the same issue in an app i was working on. For some reason, it didn't work for me either. I suggest you try creating the the scrollview and the view inside it programatically instead of storyboard for this particular view controller. It will work like a charm. You will also have to find the length of the inner view and then set the size of the scroll view to the size of the view embedded in it.
I figured it out. Not sure if this is the preferred method or just a work around.
The main difference is I connected the last ScrollView, not the First one. Not sure why but it works.
Before, (pics above in original post with cut off button), it would cut off my UIView. I still would like to know "why" it does this. Thanks for the reply's.

Resources