简体   繁体   中英

Creating Table Views Based off an Array with Swift

Is there a way that would allow me to create tables within a view controller and then position them? I have an array "items" that would output the total amount of TableViews -1. So for instance if the array "items" contained 15 items, 14 TableViews would be created.

Can you add n tableView s to a single view controller? Yes, but it's not practical or reasonable to write the amount of code you'd need to manage a varying number of layouts and delegates.

A tableView is designed to scroll (sections or) rows of cells, not to show a single item on screen. If you are determined to layout each item, you would be better off using a (much lighter) custom view instead of a tableView .

However, a single UICollectionView can do what you want to do. Yes, you'd have to write some code to manage the flow layout, depending on the number of brackets it had to display, but you could easily manage a grid-based approach with each column (round) showing teams and score.

This would certainly be more intuitive and practical to have a single scrollable region, where each bracket is able be selected and interacted with, instead of trying to add multiple tableViews to a view (controller).

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