iOS

UIViewController Lifecycle

UIViewController lifecycle, viewDidLoad, viewWillAppear, transitions, memory warnings

20 câu hỏi phỏng vấn·
Junior
1

What is the loadView method in the UIViewController lifecycle?

Câu trả lời

loadView is called to create the controller's root view. It is invoked before viewDidLoad and should only be overridden if the view is created programmatically without Interface Builder. It is the first stage of the lifecycle, ideal for building the root view hierarchy. Never call super.loadView() when overriding as it would load the default xib/storyboard.

2

When is viewDidLoad called in the lifecycle?

Câu trả lời

viewDidLoad is called once after the view has been loaded into memory, after loadView. It is the ideal time to configure IBOutlets and initialize internal state. This method is never called again during the controller's lifetime.

3

What is the role of viewWillAppear in the lifecycle?

Câu trả lời

viewWillAppear is called before the view is displayed on screen. It can be invoked multiple times during the controller's lifetime. It is the appropriate place to make changes that should happen each time the view appears, such as refreshing data.

4

What is the difference between viewWillAppear and viewDidAppear?

5

What is the purpose of viewWillDisappear?

+17 câu hỏi phỏng vấn

Nắm vững iOS cho lần phỏng vấn tiếp theo

Truy cập tất cả câu hỏi, flashcards, bài kiểm tra kỹ thuật, bài tập code review và mô phỏng phỏng vấn.

Bắt đầu miễn phí