问题
I'm writing application for iOS 4.1+ and I had to add tab bar to view controller programmatically.
Here is the code of main ViewController:
- (void)viewDidLoad
{
FirstViewVC* vc1 = [[FirstViewVC alloc] init];
vc1.tabBarItem.title = @"Tab 1";
AboutVC* vc2 = [[AboutVC alloc] init];
vc2.tabBarItem.title = @"About Program";
NSArray* controllers = [NSArray arrayWithObjects:vc1,vc2, nil];
tabBarController.viewControllers = controllers;
self.tabBarController.view.frame = [[self view] frame];
tabBarController.view.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleHeight;
self.view.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleHeight;
[self.view addSubview:tabBarController.view];
(...) //deallocs
}
The result looks like this:
http://img152.imageshack.us/img152/5176/nohotspotup.png
Now, if I turn on personal hotspot, everything is sliding down:
http://img528.imageshack.us/img528/9348/img0028y.png
As you can see tabbar is cut off. I've tried many ways of applying resize masks and adding tabbar, but I still can't manage to get this working properly.
Is there a way to fix this?
回答1:
This isn't a bug, it can also occur if you answer the phone and then switch over to your app when the call is still active.
This is something you need. To take into consideration when laying out the UI and make sure that the UI reverts to it's desired state when that bar goes back to the normal size, that's another small thing to take care of.
Also, you can test this probably easier on the simulator if you open up iChat - I guess now you should use the FaceTime app on Mountain Lion, this should set that top bar green because of an "active call", I tried to get rid of this for the simulator in vain because I was conferencing and developing which caused a problem, but a good one, because I then layed out my UI properly.
来源:https://stackoverflow.com/questions/11902405/ios-4-1-personal-hotspot-pushing-down-tabbar