UIKit & graphicsHistorical technical note
Disabling the system swipe-back gesture on iOS
Addresses an embedded game unexpectedly revealing navigation and tab bars during a swipe. The article shows where to control the navigation controller's built-in back gesture and records how that interaction was disabled for a particular screen.
Originally credited to Bison. Content is retained as published.
On this page
"Health is the foundation of everything. Getting more exercise is the way to go." Bison
A recent project contained an embedded game and had this issue: swiping left made the navigation bar and tabbar appear. That led to the code below.
The code is as follows
Core code
// 禁用返回手势,需要开启只需设置为yes即可。默认开启
if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
self.navigationController.interactivePopGestureRecognizer.enabled = NO;
}