Search code examples
iosuinavigationcontrolleruitoolbar

iOS - UIToolbar resized after returning from background


I have a toolbar that I've manipulated to take up a bit more screen real estate. The problem is when the app comes back from the background it is re-sized to the stock size and I can't seem to re-size it again.

How I'm currently modifying it is just via self.naviagtionController.toolbar.frame = CGRectMake(X,Y,W,H);

Also I'm using the navigationController toolbar. (and I have a very specific reason for using the navigationControllers toolbar)


Solution

  • So your checking for the app became active notification and then setting the toolbar size. You then set a custom size and after you set the size something comes along and changes it back to the default size. Is that about it?

    I think there would be a better way to do it, but...

    You could try delaying your change till the main run loop executes. You can do this by using GCD to put the action on a background thread which puts it back on the main thread.

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        dispatch_async(dispatch_get_main_queue(), ^{
            // set toolbar frame
            self.naviagtionController.toolbar.frame = CGRectMake(X,Y,W,H);
        });
    });