Temporary extra space on top of UICollectionView w/ navigation bar - swift

There are a couple of things wrong with my UICollectionView and corresponding cells that are under a navigation bar. First of all, when the view first loads, there seems to be some extra space on the top. But when I do a little scroll down (not a full scroll), it adjusts to normal height. Check out the images below for what I mean. this is what I see when i first open the view controller
after a little scroll, not a full one (There are 10 cells in this VC), i see this. Why is this happening?

In your viewcontroller uncheck Adjust Scroll View Insets

Go to your storyboard in your view controller select your collectionView and from the side pane select size inspector there is an option of content insets set it to Never.

Related

Scroll content over fixed background image in swift

I am trying to achieve a scrolling over a fixed image, as you can see on the picture.
I thought I should use a scrollview but I didn't quite get it how to use it and what to include into the scrollview, since the image and the button on the bottom should be fixed. In addition, the content should only be scrollable, when the text is to long.
I think the best solution here would be using a UITableView inside a UIViewController.
You can then set up the cells to make it look exactly the way you want.
For instance the first cell would just be the image, the second cell would be your title, the third one would be your menu bar, and so on.
This may be really useful if you plan to present dynamically the elements inside your UIViewController (for example if you need to use a database, you may want to animate the insertion of the rows only if the content has be downloaded already)
So using a UIViewController, you can just add the UITableView to it and set it up using contraints so that it fills the entire view. Then you can just add your button on the top of your table view, as a subview of your UIViewController's view (not as a subclass of your table view otherwise your button would end up scrolling too).
And again here you would need to add a few constraints to your button to make it look alright!
Just try it like this and let me know if you have any difficulties in the implementation :)
It is very complex to explain, To understand you must know good autolayout
To achieve that you need two scrollview and little math :)
Suppose your headerview height is 200
As you know when using autolayout we need following view hierarchy
Your view Hierarchy should be
--> Main View
--> ScrollView
--> Container View
-->Your HeaderView (200)
-->Content View (Equal height to UIView)
--> UIView (Your tabs like button , followbutton)
--> ScrollView 2
--> ContainerView
-->Subviews
Scroll view 1 Will used wo scroll the headerview and second scrollview will used to scroll other content of scrollview (Like Tab and text content as shown in picture )
Content View (Equal height to UIView) will allow your content view to give height of 200 extra to scroll bottom and your second scrollview will scroll to top which will allow to scroll your other content too
https://media.giphy.com/media/a2A4AQeAIkAhO/giphy.gif

how to scroll smoothly to see all the items in the tableview in iOS

I am doing a tableview which is customized by tableviewcell, but when I scroll it up and down, the last item just shows the half of image (each row has image on the left) and also has no any letter(3 text labels) showed like the other items. How can I make it better to scroll down or up to see all the items?
Are you sure your UITableView is the correct size?
If you have a status bar and navigation bar the tableview should be 416px tall

UITableView has blank space below, can't remove

I have a UITableView that displays some data that is read in at runtime and features a button below it that will refresh the list when clicked. All of that works fine, however there is a problem with the layout on the simulator.
When I run, there is a space at the bottom of the table that pushes the refresh button down. No matter how long the UITableView is, the UIButton will always be kept at that extended distance. If I overlay the bottom with the UIButton, it does display with slightly less padding. I am at a loss of how to fix this.
Image with example of behaviour: http://img864.imageshack.us/img864/9913/screenshot20120326at113.png
I think the problem is that in the interface builder your layout does not show at the same size, because it lacks the navigation bar at the top.
In the visual editor, choose the window hosting your table view, go to the attribute inspector, and choose Navigation bar for the Top Bar entry in the Simulated Metrics section of the inspector. The layout of your design will change. Resize your table view, move your button, rebuild the app, and run it again; this should do the trick.
It looks like it's because you're designing without the navigation bar simulated and you've set up your autoresizing masks incorrectly.
What you can do is either enable the simulated metric (attributes inspector in IB with the main view selected) for the top bar set to Navigation Bar, or you can go and fix your autoresizing masks. They are the red things in the size inspector in IB.
It is because when you designed the screen you didn't consider the navigation bar that is gonna come. Simply add a bar to the screen on the top and rearrange the table and button with proper autoresizing masks. It will fit.

Scrolling through UIScrollView in Interface Builder for Xcode 4

This seems to me as though it would be a common problem, but I can't seem to find the answer anywhere. This question seems to address the issue, but I can't seem to get the solution to work and I'm not sure it's referring to Xcode 4.
When using Interface Builder in Xcode 4 and working with a UIScrollView, is there a way to scroll the view down in Interface Builder itself to view/add/edit controls that are out of the viewable section of the screen? I've managed to push a couple controls down using the arrow keys, but now I can't see them and therefore can't manipulate them in Interface Builder. Scrolling the view in IB would be first prize, but if there's a way to even select the controls using a drop-down menu or whatever so I can push them back up with the arrow keys, that would at least be something. Thanks.
Set the ViewController's Simulated Size to Freeform and set a very large height. E.g: 1000 and voilà! You can now scroll to see all the stuff and add even more! :)
P.S: Remember to set set Fixed when you are finish to avoid problems!
Just a workaround which helps in Xcode4:
Expand the Objects Panel which resides on the left of the Interface Builder view (there is the tiny arrow at the bottom of the panel).
Drag your UIScrollView from the view hierachy and place it on the top level.
Now you can resize it to access more content (scrolling to that content did not work for me).
When you are done adding child views to the scrollview, you need to resize it back to be smaller or the same size as the parent view.
After your changes you would need to put back the scroll view where it belongs in your hierachy
I typically do the following when I want to (have to) build a long scrolling screen:
Set the size of the View Controller to Freeform
Set the height of the top level View to something very large
Arrange all the controls that I want on the View
Select all the controls
Select Editor->Embed In->Scroll View
Set the size of the View Controller back to normal (typically Inferred)
Well, there are a few different things you can do. There is a list of items in your view you can open on the left of the workspace by clicking the button that looks like a little play button on the toolbar. Double clicking any item selects it so you can use the arrow keys.
The best option is to use the layout panel (typically on the right) and enter position values manualy. Sometimes I will use this to move my scrollview up to where I can see where I'm working then move it back.
I found a solution although you have to use a Table view controller. If you define the table as static, the scroll works in interface builder when the table is bigger than the windows size. Moreover, a standard view can be added to the top and bottom of the table, these views are scrollable as well. The scroll is made once the controller is selected. I hope you find this trick useful.
I know this isn't exactly what you were looking for, but I always just drag the scroll view out of the view controller onto the "pasteboard" where you can resize it at will and see the whole thing.
Once I make my edits I simply resize it to fit it's allotted space in my view and place it back in the view controller.
set the root view to freeform and ~1000 pt height, go through the child views and set them to this height as well(including scroll view), in the viewdidload method set the height to the appropriate size.

Iphone tableview horizontal scrollbar appear

I have tableview that scroll vertically. My question is when first this view is loaded, horizontal scrollbar appears at the bottom of tableview and disappears. It only happens when the view loads at the first time. I wonder why this is happening.
I'd hazard a guess that you accidentally checked the “Horizontal Scrollers” box in the table's properties in Interface Builder. To turn them back off again, either find that (under the “Scroll View” section of the inspector) and uncheck it, or just set the table view's showsHorizontalScrollIndicator property to NO in your controller's -viewDidLoad.