LoginSignup
1
1

More than 5 years have passed since last update.

UISearchController 使ってると出てくる、Attempting to load the view of うんたらかんたら

Last updated at Posted at 2017-04-13

UISearchController 使ってたら、ViewController が dealloc されるタイミングで、こんなログが出てきてました。

Attempting to load the view of a view controller while it is deallocating is not allowed and may result in undefined behavior (<UISearchController: 0x17805800>)

ぐぐってみると StackOverflow なんかでも同じように出てる人がいっぱいいるようですが、
何故か

「こうすると解決するよ!」

っていう返答に対して、

「いやそれじゃ解決しなかったよ」

っていうのばかりのようです・・・。
ちなみに、私の場合はこれで解決しました。

ViewController.m
- (void)dealloc
{
    // 解決!
    [searchController.view removeFromSuperview];
}

最初、

ViewController.m
- (void)dealloc
{
    // 間違い!
    [searchController.searchBar removeFromSuperview];
}

のように、
「searchController.view

「searchController.searchBar
と書いて、俺も解決しない!って騒いでました・・・w

1
1
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
1
1