I want to make a uiwebview full screen on user single tap?
So I got the idea to fix the height of that uiwebview and insert some blank spaces on top and bottom of the content. So when user tab the navigation bar and tool bar get hidden animatedly.
But the problem is I am not able to fix the height of that uiwebview and when user tap it, the bars get hidden but th开发者_高级运维e uiwebview moves to the and the view is shown only in only in half screen.
So tell me the way to fix the size of UIwebview so that the navigation bar and tool bar get drawn above it.
provide me any sample code.
Try this webView.autoResizingMask = UIViewAutoresizingFlexibleHeight;
What is a UIAutoresingMask value in webView? By default (in Interface Builder) it's full mode. Try to change it.
I have a same sort of feature. If a user swipes with 3 fingers down, the toolbar is animated offscreen and a webview is animated to fill the screen.
my Code:
static BOOL toolbarHidden = NO;
- (void)increaseScreensizeGestureDone
{
// toolbar animation
[UIView beginAnimations:@"toolbar" context:nil];
if (toolbarHidden)
{
toolbar.frame = CGRectOffset(toolbar.frame, 0, +toolbar.frame.size.height);
toolbar.alpha = 1;
toolbarHidden = NO;
webView.frame = CGRectMake(0,
webView.frame.origin.y + toolbar.frame.size.height,
webView.frame.size.width,
webView.frame.size.height - toolbar.frame.size.height);
}
else
{
toolbar.frame = CGRectOffset(toolbar.frame, 0, -toolbar.frame.size.height);
toolbar.alpha = 0;
toolbarHidden = YES;
webView.frame = CGRectMake(0,
webView.frame.origin.y - toolbar.frame.size.height,
webView.frame.size.width,
webView.frame.size.height + toolbar.frame.size.height);
}
[UIView commitAnimations];
}
I hope my code helps.
EDIT:
My first code was with a 'CGRectOffset' at the webview too, but I could not get the wanted result.
(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
if(fullWebView){
[self.navigationController hidesNavBarWhenPushed];
fullWebView=FALSE;
self.navigationController.navigationBar.hidden=TRUE;
}
else {
[self.navigationController hidesBottomBarWhenPushed];
fullWebView=TRUE; self.navigationController.navigationBar.hidden=FALSE;
}
}
(BOOL)hidesNavBarWhenPushed {
return (fullWebView?TRUE:FALSE)
}
// you can set the size of UIWebView based on condition
精彩评论