所以,我希望iOS7滑动到后退手势与我的自定义后退按钮一起工作.搜索并尝试了不同的方式,但似乎没有一个很有希望.我能得到的最接近的是http://keighl.com/post/ios7-interactive-pop-gesture-custom-back-button/.
但是,现在当我继续推送并d出导航堆栈时,堆栈中的rootVIEwController会停止响应任何触摸.
有什么建议?
解决方法 像keighl建议的那样,对UINavigationController进行子类化是正确的方法.但他错过了对根视图控制器的检查,以避免在根视图上执行手势时冻结.这是一个带有附加检查的修改版本:
CBNavigationController.h:
#import <UIKit/UIKit.h>@interface CBNavigationController : UINavigationController <UIGestureRecognizerDelegate,UINavigationControllerDelegate>@end
CBNavigationController.m:
#import "CBNavigationController.h"@interface CBNavigationController ()@end@implementation CBNavigationController- (voID)vIEwDIDLoad{ NSLog(@"%s",__FUNCTION__); __weak CBNavigationController *weakSelf = self; if ([self respondsToSelector:@selector(interactivePopGestureRecognizer)]) { self.interactivePopGestureRecognizer.delegate = weakSelf; self.delegate = weakSelf; }}- (voID)pushVIEwController:(UIVIEwController *)vIEwController animated:(BOol)animated{ NSLog(@"%s",__FUNCTION__); if ([self respondsToSelector:@selector(interactivePopGestureRecognizer)]) self.interactivePopGestureRecognizer.enabled = NO; [super pushVIEwController:vIEwController animated:animated];}#pragma mark UINavigationControllerDelegate- (voID)navigationController:(UINavigationController *)navigationController dIDShowVIEwController:(UIVIEwController *)vIEwController animated:(BOol)animate{ NSLog(@"%s",__FUNCTION__); // Enable the gesture again once the new controller is shown AND is not the root vIEw controller if (vIEwController == self.vIEwControllers.firstObject) { if ([self respondsToSelector:@selector(interactivePopGestureRecognizer)]) self.interactivePopGestureRecognizer.enabled = NO; } else { if ([self respondsToSelector:@selector(interactivePopGestureRecognizer)]) self.interactivePopGestureRecognizer.enabled = YES; }}@end
objective-c
总结以上是内存溢出为你收集整理的ios7 – 使用自定义后退按钮滑动手势会冻结根视图控制器全部内容,希望文章能够帮你解决ios7 – 使用自定义后退按钮滑动手势会冻结根视图控制器所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)