我有一个UIWebView只覆盖屏幕右侧的大部分。 为此,我使用frame属性为纵向定义了框架大小和位置。 webView.frame=CGRectMake(220,100,548,875);
UIWebView大小旋转时不正确
当设备旋转为横向,我指定横向方向的新框架: webView.frame=CGRectMake(300,73,724,638);
问题是,当我再次旋转web视图从纵向到横向和纵向和我改变了框架原来的一个,它的宽度只有从之前一个半..
这里是我的代码和函数调用来调整框架:
-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
if(toInterfaceOrientation==UIInterfaceOrientationPortraitUpsideDown)
{
}
else if(self.interfaceOrientation==UIInterfaceOrientationPortrait)
{
[self showLandscape];
}
else if(toInterfaceOrientation==UIInterfaceOrientationPortrait)
{
[self showPortrait];
}
}
-(void)showLandscape
{
.
.
.
webView.frame=CGRectMake(300,73,724,638);
.
.
.
}
-(void)showPortrait
{
.
.
.
webView.frame=CGRectMake(220,100,548,875);
.
.
.
}
如何解决这个问题?
是'webView'动态创建的吗? – holex 2012-07-25 08:48:54
是的webView是动态创建 – aswin 2012-07-25 08:54:46
你可以采取一些截图吗? – holex 2012-07-25 09:00:58