When starting the app, if the user doesn\'t have login information stored, I want to display a modal view controller to force the entry of this information. I found through
I am running into the same problem. I admit that I may have taken a nontraditional route, embedding a tab bar in a NavController, and now I'm kinda seeing why they say not to do it. Well, whatever, it makes sense for my app, even if it is a total pain to implement.
My problem is that once I pushed a Modal VC onto a TabController subview (which is, in turn, a subview of the overarching NavController View, which has control of the top NavBar... which turns into a delegation nightmare) and then dismiss the MVC, the view that comes back is pushed up under the NavBar. Doesn't happen when I add or push any other subviews, just with MVCs.
[self.view setFrame:(CGRect)] does seem to do the trick, if I call it right after [self dismissModal...]. However, it has to be called on all subviews of my tab bar controller, or even the other lists are shunted up under the bar. Poopy.
Makes things a headache, but not unsolvable. But I agree, this is a new bug with 3.x (or maybe it's one of those double-edged "new features"), and it's downright annoying. I'm downloading 3.1.2 SDK now, and hopefully it addresses this. Gonna comment my [setFrame] lines and see what happens. But hopefully, if it's not solved in this version, it will be soon. Until then, it seems that the solution is a lot of (admittedly hackerish and repetitive) code.
EDIT: Nope, updating didn't help. Poop. Back to the code I go, to hard-define the position of every screen. Awesome. Hopefully the size of Nav and Tab Bars doesn't ever change.
EDIT 2: Hey! I solved it! (i R prowd.) Seems the problem was that, when my MVC was dismissed, my view got passed back to the tab bar controller, which had "forgotten" it had a nav bar above it. Don't tell me how, I'm probably way out of documented territory by now. But, I solved my particular problem by simply redefining the [subview.view setFrame:0,0,width, height] after returning from editing. Not sure why this made any difference, but in the app it did, because no longer is the first one and a half rows of my table view sneaking up under the nav bar. So I really have no advice, just find the right place to put
[(appropriateViewController).view setFrame:CGRectMake(0,0,self.view.frame.size.width, self.view.frame.size.height];
Not sure why it works but it does. Isn't that the worst kind of error?
I ran into the same issue. Not sure what causes it, but I fixed it with the following line of code just after I dismiss my modal view:
[self.view setFrame:CGRectMake(0, 10, self.view.frame.size.width, self.view.frame.size.height)];
Just adjust the Y offset to meet your needs. In another instance I had to make it 20 instead of 10.
Just wanted to chime and say I had the exact opposite problem - a white gap at the bottom of the screen. And the fix was also the opposite, I was presenting from a subview, when I needed to be presenting from the parent. Thanks!
I had the exact same problem... my solution? Manually set the height of the view you're displaying modally to 480 px in interface builder.
Problem solved.
In case anyone looks at this post (I did today and so others might). I am a newbie to objective c but and you may laugh at my suggestion but here goes.
When running my iPad app the status bar was always overlapping my form. I wasn't happy to use the method for changing the frame coordinate down 20px so went searching.
Found that if I was to assign my custom view controller to the window rootViewController then the status bar overlap problem went away. I haven't tried the modal stuff in this post but hope this helps other newbies who may be wondering how to sole this problem.
This is what a simple AppDelegate didFinishLaunchingWithOptions method would look like:
(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
TEGGameViewController *gameVC = [[TEGGameViewController alloc] init];
self.window.rootViewController = gameVC;
[self.window makeKeyAndVisible];
return YES;
}
The given answer is hard to understand, more like a vague hint, so it's a try to explain more detailed:
The problem is that the root view controller which viewDidAppear:
method is presented in the question looks like to a be simple UIViewController
. And how we can see in Apple's documentation for wantsFullScreenLayout
:
The default value of this property is NO, which causes the view to be laid out so it does not underlap the status bar
This root view controller presents UINavigationController
modally, so presented navigation controller uses not the whole screen. Also it seems that default UINavigationController
's value for wantsFullScreenLayout
is YES
. That's why navigation controller adds the gap — to avoid underlapping the status bar with navigation bar.
So there are several ways to solve it:
1) Present navigation controller with wantsFullScreenLayout
property set to NO. (Or to present ~fresh UIViewController with a UINavigationController
's view as a subview)
2) Change the rootViewController
property of UIWindow
to navigation controller manually, so navigation controller is presented on the whole window. Can use it e.g. when the first screen is kind of disposable pin/password input, and we can easily drop it after successful login and change for navigation controller.