- (void)viewDidLoad {
[super viewDidLoad];
self.title = @"隐藏导航栏";
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.backgroundColor = [UIColor lightGrayColor];
button.frame = CGRectMake(10, 100, 60, 30);
[button addTarget:self action:@selector(buttonClick) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button];
self.navigationController.delegate = self;
}
- (void)buttonClick{
///跳转到KKViewController
[self performSegueWithIdentifier:@"pusht" sender:nil];
}
@interface ViewController ()<UINavigationControllerDelegate>
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
[self.navigationController setNavigationBarHidden: [self hiddenBarVc: viewController] animated: animated];
}
- (BOOL)hiddenBarVc:(UIViewController *)viewController {
BOOL needHideNaivgaionBar = NO;
if ([viewController isKindOfClass: [KKViewController class]]) {
needHideNaivgaionBar = YES;
}
return needHideNaivgaionBar;
}
@property (nonatomic,strong) id popDelegate;
- (void)viewDidLoad {
[super viewDidLoad];
self.title = @"第二个页面";
[self popSet];
}
- (void)popSet{
_popDelegate = self.navigationController.interactivePopGestureRecognizer.delegate;
SEL action = NSSelectorFromString(@"handleNavigationTransition:");
UIPanGestureRecognizer *popPanGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self.popDelegate action:action];
popPanGesture.maximumNumberOfTouches = 1;
popPanGesture.delegate = self;
[self.view addGestureRecognizer: popPanGesture];
}
@interface KKViewController ()<UIGestureRecognizerDelegate>
- (BOOL)gestureRecognizerShouldBegin:(UIPanGestureRecognizer *)gestureRecognizer{
///【下面两个方法写一个】
///全屏拖动
CGPoint tragPoint = [gestureRecognizer translationInView:gestureRecognizer.view];
if (tragPoint.x <= 0){
return NO;
}
else{
if (self.navigationController.viewControllers.count <= 1){
return NO;
}
else{
return YES;
}
}
// ///局部允许拖动
// CGPoint tragPoint = [gestureRecognizer locationInView:gestureRecognizer.view];
// NSLog(@"x=%f;y=%f",tragPoint.x,tragPoint.y);
// if (tragPoint.x > 60){///拖动的范围
// return NO;
// }
// else{
// if (self.navigationController.viewControllers.count <= 1) {
// return NO;
// }
// else{
// return YES;
// }
// }
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有