LoginSignup
39
23

More than 5 years have passed since last update.

iOS11からUITableViewにスペースができてしまう

Last updated at Posted at 2017-08-25

UITbaleView(UIScroll Viewスクロールで更新などで使っていたスクロールビュー部分)がiOS11のシミュレーターではずれてしまう問題。

理由としては今まで、navigation bar分を手動で調整していた場合に、iOS11からはUIScrollViewContentInsetAdjustmentBehaviorが追加されて自動で(自動がデフォルトになったため)変更するようになったためである。

詳細は以下の通り
UIScrollViewContentInsetAdjustmentBehavior

contentInset.top

tableView.contentInset
を検索して引っかかればその可能性大

なので、今までの実装を変えずにとりあえずデザイン崩れを直すには新しく追加されたUIScrollViewContentInsetAdjustmentBehaviorのデフォルトのautoからこの調整部分をnoneを以下のように変更するか独自に調整していた部分をiOS11以上では設定しないようにすればいい。

if (@available(iOS 11.0, *)) {
     scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
} 
39
23
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
39
23