3

是否可以隐藏 a UIToolBarandUINavigationBar并用 a 这样做UITouchGestureRecognizer但同时展开 theUIWebView以占用其余空间?还反过来做同样的事情?

提前感谢大家!

4

2 回答 2

3

要隐藏顶部导航栏,请使用navigationBarHidden属性或setNavigationBarHidden:animated:方法(如果您希望它具有动画效果)。同样,使用底部工具栏的toolbarHidden属性或setToolbarHidden:animated:方法。这些是UINavigationController.

如果您想为工具栏隐藏和UIWebView扩展设置动画,请将大小的更改包装UIWebView在一个UIView animateWithDuration...方法中。

添加您选择的手势识别器。对于滑动,创建一个实例UISwipeGestureRecognizer并将其添加到您的视图中。在你的viewDidLoad方法中是这样的:

UISwipeGestureRecognizer *swipeGestureRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipe)];
[self.view addGestureRecognizer:swipeGestureRecognizer]; 

滑动处理程序如下所示:

-(void)handleSwipe{
    if (self.navigationController.navigationBarHidden) {
       [self.navigationController setNavigationBarHidden:NO animated:YES];
        [self.navigationController setToolbarHidden:NO animated:YES];
       [UIView animateWithDuration:0.3 animations:^{
            self.webView.frame = CGRectMake(self.webView.frame.origin.x, self.webView.frame.origin.y, self.webView.frame.size.width, self.webView.frame.size.height - 88);
        }];
    } else {
        [self.navigationController setNavigationBarHidden:YES animated:YES];
        [self.navigationController setToolbarHidden:YES animated:YES];
        [UIView animateWithDuration:0.3 animations:^{
            self.webView.frame = CGRectMake(self.webView.frame.origin.x, self.webView.frame.origin.y, self.webView.frame.size.width, self.webView.frame.size.height + 88);
       }];
    }
}
于 2012-12-31T04:30:14.377 回答
3

采用

-(void)didTap
{
[self.navigationController setNavigationBarHidden:YES animated:YES];
//remove your tool bar from superview
[toolbar removeFromSuperview];
//code to add ur UIWebView

}
于 2012-12-31T04:41:36.137 回答