Skip to content

Instantly share code, notes, and snippets.

View xuanvinhtd's full-sized avatar

Hồ Xuân Vĩnh xuanvinhtd

View GitHub Profile
@xuanvinhtd
xuanvinhtd / tableViewKeyboardHandling.m
Created March 24, 2018 03:38 — forked from TimMedcalf/tableViewKeyboardHandling.m
The easy & reliable way of handling UITableView insets when the keyboard is shown. This works unchanged no matter where the table view is on the screen (including dealing with orientation, hierarchy, container view controllers & all devices)
/*
One of the first things someone new to iOS Development finds is that dealing with the keyboard is trickier
than they think it should be. Simply changing the scrolling extents of a UITableView (or UIScrollView, or
UICollectionView) that is partially covered by they keyboard reveals a lot about the internals of how iOS
works and highlights various "gotchas" that need to be considered.
There are various ways to know that a keyboard has been shown - but observing some specific notifications
provides a reliable way to allow you to modify your views to deal with it.