Question

I am trying to load in a view (with a Date Picker) on top of a Tab Bar that's loaded in as a subview in my apps delegate files.

I do it like this:

[[[UIApplication sharedApplication] keyWindow] addSubview:viewWithPicker];

It works, but it leaves a small gap at the bottom, just big enough to show the tab bar.
How can you remove the subview again after adding it?

Does anyone know how to fix it? Thanks :)

Was it helpful?

Solution

You are responsible for setting viewWithPicker's frame or center property correctly so that it will appear at the correct position.

OTHER TIPS

Did you in Interface Builder configure it to leave space at the bottom for a ToolBar or otherwise set the size to anything that would make it smaller than the full size (480 x 320px)?

If you are adding it as a subview to a ViewController that is using a ToolBar you might want to check this question for more information.

The key window takes up the full screen size (320 x 480), however, the status bar is drawn above the key window at all times.

When you add a subview to the key window without settings its frame or centre manually, its origin will be placed at (0,0), which the status bar is drawn on top.

The space you're seeing at the bottom of the view is because your view likely has its height set to 460, which happens if the view was created in Interface Builder and has the "simulated interface elements" set to show the status bar.

You'll need to change the subview's y value to position it below the status bar. 20 is usually a good value to use, since that's the status bar's height. However, the status bar height may change in future versions of the iPhone OS, so hardcoding values like that is a bad idea.

I fixed it!

As simple as setting the overlay view to 480px height.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top