在iOS7中,新增加了一個小小的功能,也就是這個api:
self.navigationController.interactivePopGestureRecognizer.enabled = YES;
這個api功能就是在NavigationController堆棧內(nèi)的UIViewController可以支持右滑手勢,也就是不用點擊右上角的返回按鈕,輕輕在屏幕左邊一滑,屏幕就會返回,隨著ios設(shè)備屏幕的增大,這個小功能讓手指短,拇指大和手殘人士看到了福音。
這個功能是好,但是經(jīng)常我們會有需求定制返回按鈕,如果手動定制了返回按鈕,這個功能將會失效,也就是自定義了navigationItem的leftBarButtonItem,那么這個手勢就會失效。解決方法找到兩種
1.重新設(shè)置手勢的delegate
self.navigationController.interactivePopGestureRecognizer.delegate = (id)self;
2.自己響應(yīng)這個手勢的事件
[self.navigationController.interactivePopGestureRecognizer addTarget:self action:@selector(handleGesture:)];