Interview Questions

Get ready for your next interview with our comprehensive question library

UIKit Interview Questions

Filter by Difficulty

1.

What is the difference between UIView and UIViewController?

beginner

UIView is the fundamental building block for all visual elements in iOS. It represents a rectangular area on the screen and handles drawing and user interaction within that area. Views can contain other views (subviews) and form a view hierarchy.

UIViewController manages a collection of views and coordinates the logic between the model and view layers. It handles view lifecycle events, user interactions, and navigation between different screens.

// UIView - represents visual element
let myView = UIView(frame: CGRect(x: 0, y: 0, width: 100, height: 100))
myView.backgroundColor = .blue

// UIViewController - manages views and logic
class MyViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        view.addSubview(myView)
    }
}
2.

Explain the view hierarchy in UiKit.

beginner

The view hierarchy is a tree-like structure where views contain other views as subviews. Each view has a superview (parent) and can have multiple subviews (children). The root view is typically managed by a view controller.

Key characteristics:

  • Child views are drawn on top of their parent views
  • Coordinate systems are relative to the superview
  • Events bubble up through the hierarchy
  • Views inherit certain properties from their superviews
let parentView = UIView()
let childView1 = UIView()
let childView2 = UIView()

parentView.addSubview(childView1)
parentView.addSubview(childView2)
// childView2 will be drawn on top of childView1
3.

What are the main properties of UIView?

beginner

Key UIView properties include:

  • frame: Position and size in superview's coordinate system
  • bounds: Internal coordinate system (always origin at 0,0)
  • center: Center point in superview coordinates
  • backgroundColor: Background color of the view
  • alpha: Transparency level (0.0 to 1.0)
  • isHidden: Visibility state
  • tag: Integer identifier for finding views
  • superview: Parent view reference
  • subviews: Array of child views
4.

What is Auto Layout and why is it important?

beginner

Auto Layout is a constraint-based layout system that automatically calculates the size and position of views based on rules (constraints) you define. It's important because:

  • Responsive Design: Adapts to different screen sizes and orientations
  • Dynamic Content: Handles varying content sizes automatically
  • Internationalization: Supports different languages and text directions
  • Accessibility: Works with Dynamic Type and accessibility features

Auto Layout uses mathematical relationships between views instead of fixed frames, making UIs flexible and maintainable.

5.

Explain the difference between UITableView and UICollectionView.

beginner

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
6.

What is UINavigationController and how does it work?

beginner

Upgrade to Premium to see the answer

Upgrade to Premium
7.

What is the difference between frame and bounds?

intermediate

Upgrade to Premium to see the answer

Upgrade to Premium
8.

Describe the view controller lifecycle methods and their purposes.

intermediate

Upgrade to Premium to see the answer

Upgrade to Premium
9.

When would you use viewWillAppear vs viewDidLoad?

intermediate

Upgrade to Premium to see the answer

Upgrade to Premium
10.

What is the purpose of loadView() and when should you override it?

intermediate

Upgrade to Premium to see the answer

Upgrade to Premium
11.

What are the different types of constraints in Auto Layout?

intermediate

Upgrade to Premium to see the answer

Upgrade to Premium
12.

What is content hugging and compression resistance priority?

intermediate

Upgrade to Premium to see the answer

Upgrade to Premium
13.

How do you resolve Auto Layout conflicts?

intermediate

Upgrade to Premium to see the answer

Upgrade to Premium
14.

What is intrinsic content size?

intermediate

Upgrade to Premium to see the answer

Upgrade to Premium
15.

What is cell reuse and why is it important?

intermediate

Upgrade to Premium to see the answer

Upgrade to Premium
16.

How do you implement a custom table view cell?

intermediate

Upgrade to Premium to see the answer

Upgrade to Premium
17.

What are the required and optional methods of UITableViewDataSource?

intermediate

Upgrade to Premium to see the answer

Upgrade to Premium
18.

How do you implement swipe actions in a table view?

intermediate

Upgrade to Premium to see the answer

Upgrade to Premium
19.

How do you pass data between view controllers?

intermediate

Upgrade to Premium to see the answer

Upgrade to Premium
20.

What is the difference between modal presentation and navigation?

intermediate

Upgrade to Premium to see the answer

Upgrade to Premium
Showing 1 to 20 of 39 results

Premium Plan

$10.00 /monthly
  • Access all premium content - interview questions, and other learning resources

  • We regularly update our features and content, to ensure you get the most relevant and updated premium content.

  • 1000 monthly credits

  • Cancel anytime