简体   繁体   中英

iOS CollectionView with horizontal paging instead of vertical scrolling

I'm working on a project for a client. It's an iPad pdf reader. The client wants a collection view, but instead of scrolling vertically, he wants it to use a page control. It's pretty hard to explain, but what I basically want is all the PDFs on the device in a grid, like on the iBooks app. When that grid overflows, I want to use a page control to display the extra elements on a second page (like in the weather app).

My thoughts on this were: - Create a page control with one page. - On that page, create a UICollectionView. - If the number of elements is greater than 9 add a page to the page control and add another UICollectionView, until there are enough pages to display all elements.

However, this seems horribly inefficient, so my question is if there's a better way to do this.

If your goal is to scroll sideways you can just select that in the interface builder when you have the collection view selected. Then you can make the cell as big as you want. You can even enable paging on the collection view.

In the attributes inspector, right under layout is scroll direction. Set to horizontal.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM