What is the best way to move a UIToolbar?

Posted by Ferdinand Rios on Stack Overflow See other posts from Stack Overflow or by Ferdinand Rios
Published on 2010-04-16T02:16:41Z Indexed on 2010/04/16 2:23 UTC
Read the original article Hit count: 446

Filed under:
|
|
|
|

Here is an interesting problem. On the iPhone, I have a view set up that has a toolbar on the bottom of the screen. I am currently trying to make this a universal app so that it runs on iPad as well. I would like the toolbar to be at the top of the iPad screen, so in the viewDidLoad method of the specific viewController I have the following code.

    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]];
}

The problem I am having is that the webView moves down fine, but the toolbar only moves up to about what seems to be the height of a iPhone screen. The call to errorString tells me that the webView's origin is at 0,44 (where it should be) and that the toolbar's origin is at 0,0, but it is actually somewhere in the middle of the screen!

Anybody have a clue what is going on here?

© Stack Overflow or respective owner

Related posts about ipad

Related posts about iphone