I'm trying to keep the frame
of a Collection View
that I use as Photo Gallery. But after hide in the view the UITabBarController
and the UINavigationController
, its frame changes.
That's the code I use for hiding both:
- (void)hideTabBar:(UITabBarController *) tabbarcontroller
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0];
if(IS_IPHONE_5)
{
for(UIView *view in tabbarcontroller.view.subviews)
{
if([view isKindOfClass:[UITabBar class]])
{
[view setFrame:CGRectMake(view.frame.origin.x, 568, view.frame.size.width, view.frame.size.height)];
}
else
{
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 568)];
}
}
}
else
{
for(UIView *view in tabbarcontroller.view.subviews)
{
if([view isKindOfClass:[UITabBar class]])
{
[view setFrame:CGRectMake(view.frame.origin.x, 480, view.frame.size.width, view.frame.size.height)];
}
else
{
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 480)];
}
}
}
[UIView commitAnimations];
}
- (void)showTabBar:(UITabBarController *) tabbarcontroller
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0];
if(IS_IPHONE_5)
{
for(UIView *view in tabbarcontroller.view.subviews)
{
if([view isKindOfClass:[UITabBar class]])
{
[view setFrame:CGRectMake(view.frame.origin.x, 519, view.frame.size.width, view.frame.size.height)];
}
else
{
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 519)];
}
}
}
else
{
for(UIView *view in tabbarcontroller.view.subviews)
{
if([view isKindOfClass:[UITabBar class]])
{
[view setFrame:CGRectMake(view.frame.origin.x, 431, view.frame.size.width, view.frame.size.height)];
}
else
{
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 431)];
}
}
}
[UIView commitAnimations];
}
- (void)hideNavBar:(UINavigationController *) navBarController
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0];
[self.navigationController setNavigationBarHidden:YES];
[UIView commitAnimations];
}
- (void)showNavBar:(UINavigationController *) navBarController
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0];
[self.navigationController setNavigationBarHidden:NO];
[UIView commitAnimations];
}
Here a image with my problem:
Thank you very much for your helping
I assume You are using ScrollView to present photos. I've had a simillar problem and setting in your view controller
self.automaticallyAdjustsScrollViewInsets = NO;
should help.
Default value is YES, which allows the view controller to adjust its scroll view insets in response to the screen areas consumed by the status bar, navigation bar, and toolbar or tab bar. Set to NO if you want to manage scroll view inset adjustments yourself...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With