我成功地在我的 UIWebView 上实现了 UIGestureRecognizer,如下所示:
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self
action:@selector(handleTap)];
tap.numberOfTapsRequired = 1;
[myUniqueWebView addGestureRecognizer:tap];
以下代码有一些错误,但逻辑是这样的:我想点击一个视图来隐藏 NavBar,如果它已经隐藏了,我想使用相同的逻辑来显示它。它不起作用:
-(void) handleTap {
NSInteger didHideNavBar;
didHideNavBar = 0;
if ((didHideNavBar = 0)) {
[self.navigationController setNavigationBarHidden:YES animated:YES];
didHideNavBar = 1;
NSLog(@"tap1");
}
if ((didHideNavBar = 1)) {
[self.navigationController setNavigationBarHidden:NO animated:YES];
NSLog(@"tap2");
}
}
Xcode 向我显示“tap2”消息,但没有任何反应。