我有一個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