ltewarp0lleh
ltewarp0lleh

Reputation: 73

disable auto adjust uitableView inset

UIViewController

ContainerView -> UITableViewController UIView ContainerView -> UIViewController

When the keyboard is shown, the UITableViewController in UIViewController automatically adjusts the contentInset.

So, I add this code in UITableViewController

if #available(iOS 11.0, *) {
   self.tableView.contentInsetAdjustmentBehavior = .never
} else {
   self.automaticallyAdjustsScrollViewInsets = false
}

But it does not work. How can I disable auto inset?

Upvotes: 0

Views: 4684

Answers (2)

ltewarp0lleh
ltewarp0lleh

Reputation: 73

I found the perfect solution!

UITableView.appearance().contentInsetAdjustmentBehavior = .never

just add this code in UITableViewController. and strange adjust inset all gone!

Upvotes: 3

MRizwan33
MRizwan33

Reputation: 2741

Try to apply to the ViewController which contains the ContainerView (with the UITableView inside of it). It does not work when applied to the UITableView itself.

Or via code in viewDidLoad(): self.automaticallyAdjustsScrollViewInsets = false

Upvotes: 0

Related Questions