xcode 隐藏 UIToolBar 和 UINavigation 并展开 UIWebView?- iOS
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14097289/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Hide UIToolBar and UINavigation and Expand UIWebView? - iOS
提问by Mina Dawoud
Is it possible to hide a UIToolBar
and UINavigationBar
and to do so with a UITouchGestureRecognizer
but at the same time Expand the UIWebView
so it takes up the rest of the space?
Also to do the same thing in reverse after?
是否可以隐藏 a UIToolBar
andUINavigationBar
并使用 aUITouchGestureRecognizer
但同时展开 theUIWebView
以占用其余空间?反过来做同样的事情后?
Thanks to all in advance!
提前感谢大家!
采纳答案by D_D
use
用
-(void)didTap
{
[self.navigationController setNavigationBarHidden:YES animated:YES];
//remove your tool bar from superview
[toolbar removeFromSuperview];
//code to add ur UIWebView
}
回答by bobnoble
To hide top navigation bar use either the navigationBarHidden
property or setNavigationBarHidden:animated:
method if you want it animated. Similarly, use toolbarHidden
property or setToolbarHidden:animated:
method for the bottom toolbar. These are part of UINavigationController
.
要隐藏顶部导航栏,如果您希望它具有动画效果,请使用navigationBarHidden
属性或setNavigationBarHidden:animated:
方法。同样,使用底部工具栏的toolbarHidden
属性或setToolbarHidden:animated:
方法。这些是UINavigationController
.
If you want to animate both the toolbars hiding and the UIWebView
expanding, wrap the change in size of the UIWebView
in a UIView animateWithDuration...
method.
如果要同时为工具栏隐藏和UIWebView
扩展设置动画,请将 的大小更改包装UIWebView
在一个UIView animateWithDuration...
方法中。
Add the gesture recognizer of your choice. For a swipe, create an instance UISwipeGestureRecognizer
and add it to your view. Something like this in your viewDidLoad
method:
添加您选择的手势识别器。对于滑动,创建一个实例UISwipeGestureRecognizer
并将其添加到您的视图中。在你的viewDidLoad
方法中是这样的:
UISwipeGestureRecognizer *swipeGestureRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipe)];
[self.view addGestureRecognizer:swipeGestureRecognizer];
And the swipe handler as something like this:
和滑动处理程序是这样的:
-(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);
}];
}
}