0

I'm trying to create a UITableView with multiple columns to display standings for football leagues. I have already tried creating it using multiple UITableViews (shown in the screenshot below).

Has anyone got suggestions for another approach?

UITableView Storyboard

UITableview in the simulator

1
  • Consider SwiftUI which is much more versatile than UIKit Commented Sep 20, 2022 at 17:09

1 Answer 1

1

My approach to this problem would be to have a model like:

struct TeamScoring {
    let teamName: String
    let scores: [String]
}

Then you create a TeamScoring for each team.

Regarding the view, only a single UITableView is needed. You have to create a UITableViewCell that contains labels for all the values.

In the implementation of the following delegate method, for each index you have to pass a model to the corresponding cell:

func tableView(
    _ tableView: UITableView,
    cellForRowAt indexPath: IndexPath
) -> UITableViewCell
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.