2
这是一个有趣的问题。在iPhone上,我有一个在屏幕底部有一个工具栏的视图。我目前正在尝试将其设置为通用应用程序,以便在iPad上运行。我希望工具栏位于iPad屏幕的顶部,因此在特定viewController的viewDidLoad方法中,我有以下代码。移动UIToolbar的最佳方式是什么?
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
//move the toolbar to the top of the page and move the webview down by the height of the toolbar
CGRect toolBarFrame = self.aToolBar.frame;
CGRect webFrame = self.aWebView.frame;
webFrame.origin.y = toolBarFrame.size.height;
[self.aWebView setFrame:webFrame];
toolBarFrame.origin.y = 0;
[self.aToolBar setFrame:toolBarFrame];
[Utils errorString:[NSString stringWithFormat:@"origen: x=%f y=%f", self.aToolBar.frame.origin.x, self.aToolBar.frame.origin.y]];
[Utils errorString:[NSString stringWithFormat:@"origen: x=%f y=%f", self.aWebView.frame.origin.x, self.aWebView.frame.origin.y]];
}
我遇到的问题是,web视图向下移动很好,但只工具栏上移至什么似乎是iPhone屏幕的高度。对errorString的调用告诉我,webView的原点是0,44(它应该是),并且工具栏的原点是0,0,但它实际上是在屏幕中间的某个位置!
任何人都知道这里发生了什么?
你能后所有的viewDidLoad中(如果它不设置框架,尝试后把它工作之前)之前
:
为了解决这个问题的尝试? – MathieuF 2010-10-06 21:57:39