转载自:
http://code4app.com/snippets/one/ios7%E7%A6%81%E6%AD%A2%E9%BB%98%E8%AE%A4%E5%88%92%E5%8A%A8%E8%BF%94%E5%9B%9E/5387eb91933bf0176d8b53bf#s0
在使用之前先要判断是否ios7,不然会导致crash。然后创建一个自己的navigationController继承UINavigationController。之后还要设置UINavigationControllerDelegate,这样以上的方法才能触发。最后就判断要show出来的viewController是否需要支持划动返回了。
1
2
3
4
5
6
7
8
9
10
11
|
- (
void
)navigationController:(
UINavigationController
*)navigationController
didShowViewController
:(
UIViewController
*)viewController
animated
:(
BOOL
)animated
{
if
([
self
respondsToSelector
:
@selector
(interactivePopGestureRecognizer)]) {
if
(viewController
.class
== [
MyViewController
class
])
{
self
.interactivePopGestureRecognizer
.enabled
=
NO
;
}
else
{
self
.interactivePopGestureRecognizer
.enabled
=
YES
;
}
}
}
|