How can I get a CollectionView to only load images on the bottom half, while still allow static content at the top

妖精的绣舞 提交于 2020-01-16 19:31:13

问题


I basically want to copy Instagrams and Twitters profile pages. If I add a CollectionView to the bottom half, the CollectionView only scrolls on the bottom half of the page. The cells do not go all the way to the top and consume the profile statistics in the process.

How can I make it so the profile statistics are consumed while scrolling, and the collection view takes up the whole screen? I can't seem to figure out how to make it so the cell only takes up the bottom half while the collection view takes up the whole screen.

Anyone have any ideas on how this can be done? New to Xcode here and just trying to learn some skills.

I already have it so that the images are loaded into a grid using a custom function, but then if I were to click on the image to go to the next view of a full sized image, there is no way to get the postID of that selected image, so I need the cell functionality.


回答1:


Images/Post you see in Instagram Profile screen are UICollectionViewCell and the profile details or statistics you see is HeaderView or UICollectionReusableView.

Use a vertical collection view with flow layout. Use cells for showing posts and headerView for showing details. By this way you will get the desired behaviour.

Follow these tutorials to know how it's possible-

  • CollectionView ReuasbleView

  • RayWenderlich Tutorial



来源:https://stackoverflow.com/questions/59490910/how-can-i-get-a-collectionview-to-only-load-images-on-the-bottom-half-while-sti

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!