Explain the difference between UITableView and UICollectionView.

Beginner

Answer

UITableView displays data in a single column of rows. It's optimized for vertical scrolling and is ideal for lists, settings screens, and hierarchical data.

UICollectionView displays data in a customizable grid layout. It supports multiple columns, horizontal scrolling, and complex layouts like grids, carousels, or custom arrangements.

Key differences:

  • TableView: Single column, vertical scrolling, simpler implementation
  • CollectionView: Multiple columns, any scroll direction, more flexible but complex