I have an Imageview covering half of the screen height and a tableview below it. Both are wrapped inside a UIScrollView. I want to scroll the whole view. Means inner scroll of tableview won't work and when I scroll, outer scroll will scroll image view up and then showing cells of tableview. At the end, Imageview will hide behind scroll and tableview content will take entire space. Can anybody tell me how to achieve this. ?
Thanks
I don't think you need the outer scroll view(UIScrollView). Why don't you add only the inner table view and image view to where your outer scrollview is added. The image view can be added either above or below the table view. Let say your image view is below the table view then your image view will be covered by table view. In order to make it fully visible, set the talbview's content inset top to imageview's height and its background to clear color. then you can see both image and table view contents without one covering the other. The last thing you need to do is you have to handle the image view's y position when you scroll the table view so it looks like they are in the same scroll view. Use the scroll view delegate that is already available to you and play with scroll view's content offset and image view's y position.
I answered some similar question here with some sample code. Hand off parent container's pan gesture to nested UICollectionView
It does with collection view but the main idea is same.
Related
I want to have two collection views that scrolls like this: the goal
I have achieved this but I then have the problem that when I scroll down the green collection view scrolls for alone and not the whole view: collection view with scroll
I then locked the scroll in the green collection view and put a scroll view around the whole screen. But when you scroll the collection view gets cut like this: collectionview locked
I have seen other apps like medium have two collection view that scrolls in two directions but I can not figure out have to achieve this.
Medium home
To make the scroll view able to scroll have I done this to calculate the height of the two collectio views and then setting the heigt to the scrollview:
var size : CGSize
let height = firstView.frame.height +
secondview.collectionViewLayout.collectionViewContentSize.height
size = CGSize(self.view.frame.width,height)
scrollview.contentSize = size
And my guess is that I might want to do the same for the green collection view but I have not got that to work.
Thanks!
Take a UITableView (for vertical scrolling). Put a collection view (with horizontal scrolling) in the header of the table view. By doing this, you would have horizontally scrollable view and the problem of cutting of view would be fixed. Moreover, you will not have to take another view for vertical scrolling. You will achieve that with the cells of table view.
Design like Medium (or many other apps) are easily achievable this way. A table view (vertical scrolling), a collection view (horizontal scrolling) as table view's header, and rest everything would be managed by table view. Give it a try.
when i scroll up the collection view, 3rd view has to decrease the height and move behind the 2nd view with animation, and the 2nd view has to decrease the height and move behind the 1st view with animation. and vice versa has to happen when we scroll down the collection view. for more details look on to the comment section. i have attach the example link.
enter image description here
I have a UITableView at the bottom of the screen that pulls up and then snaps back down. When it is pulled up, though, you can see the view behind it because the tableview's height is finite and less than the size of the screen.
I tried using a large footer, but that affects the snap-back of scrolling the table up.
I also tried setting a fixed height for heightForFooter and returning a large view from viewForFooterInSection, but that view gets cut off after it reaches the height returned by heightForFooter
How can I display fixed content beneath my table without affecting its scrolling?
Add a background view to your table view, and then add a subview to that view with the color you need. You can position the subview around table/section headers.
In viewDidScroll, update the y position and height of the subview.
I have a view that contains a scroll view and that scroll view has another 2 views in it: on top a standard view, and under that another view. This last view has a scroll view inside it. (a matroshka doll has nothing on this app) .
The problem is there is a button that causes the bottom view to resize and increase it's height, but the outer scroll view doesn't increase content size. So the bottom part of the bottom view (now resized to be bigger) is not visible.
Any suggestions on how to fix this mess ?
I have an app which shows two images housed within a UIScrollview.
The scrollview is of size (320, 530), underneath it is an imageview size (320,38), this acts like a dock at the bottom of this screen, ( in fact it has to be there at the bottom of all screens in this app).
As it stand the scrollview works fine and the images switch from one to anothr when the user
moves the scrollview.
The problem is, I need the scrollview height to go all the way down ( from 530 to 568), and end up behind the dock imageview, when I change its height and the height of images within it, it just stops scrolling.
Is this impossible in scrollviews? does it have to have all of its screen real estate as top view?
Any solutions for this?
Thanks.
Update :
so I worked on the alpha and the image constraints, and the bottom imnage is located properly,
still the scrolling is not functioning.this is the latest code with changes.
http://ge.tt/4LYJGWl/v/0?c
thanks.
This is certainly possible. Add a full height scroll view to the controller's view, then add the small image view to the bottom. In the scene list at the left move that image view up so it's directly underneath the main view, which will make it a subview of that view rather than the scroll view (you'll then need to move the scroll view up above the image view so the image view will appear on top). You'll probably have to change some constraints to pin it to the bottom, and give it an alpha value less than 1 so the scroll view will show through.
After Edit
This is the screen shot of the scene from your updated code:
You only have one view that's directly under the main view, your scroll view. Compare that to my image.