4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

viewDidLoadとviewWillAppearの役割例

Last updated at Posted at 2015-02-27

viewDidLoad

Table 4-1
Methods: viewDidLoad
... By the time this method is called, your view objects are guaranteed to exist and to be in a known good state.

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupView];
}
  • UITabBarControllerなどで、複数のUIViewControllerをインスタンス化する際、viewDidLoadは呼ばれる。表示されるかどうかわからない各画面のリソースを取得するのは冗長であるため、ここでリソースの取得は行わない。

viewWillAppear:animated

  • 各リソース(data, image etc..)の取得を行う。(非同期で)
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [self updateView];
}
  • 画面表示のリロード(Pull To Refreshなどによる)は、このupdateViewを再度呼ぶ。
4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?