开发者

Non Selected Tab Bar View Controllers aren't resized when device rotated

开发者 https://www.devze.com 2023-03-01 06:10 出处:网络
I\'m having problems making my app iPad compatible. I have an implementation of a custom Tab Bar, based on the post here http://www.wiredbob.com/blog/2009/4/20/iphone-tweetie-style-navigation-framew

I'm having problems making my app iPad compatible.

I have an implementation of a custom Tab Bar, based on the post here http://www.wiredbob.com/blog/2009/4/20/iphone-tweetie-style-navigation-framework.html

That all works fine apart from when the device is rotated. The currently selected view rotates and resizes perfectly. Every othe开发者_如何转开发r view rotates but does not resize to fill the space. There is a large white column down the right hand side.

I've tried adding

self.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
self.view.autoresizesSubviews = YES;

to the tab controller view.

I've added similar code to the tab's views viewDidLoad methods.

I've tried to make the willRotateToInterfaceOrientation call all the subviews rotation methods but still no luck.

Any suggestions would be more than welcome at this stage. I'm hoping i'm not overlooking something obvious but i might be. I've been at it for a few hours now

Screenshot 1 -

Non Selected Tab Bar View Controllers aren't resized when device rotated

Screenshot

Non Selected Tab Bar View Controllers aren't resized when device rotated


Ok I Solved this problem.

What I had to do was manually call a resize on all the sub views. - i added a changeFrameSize function to each sub view (just so it made the code look a little nicer)

Oh and when adding views as sub views always use belowSubView method -

[self.view insertSubview:viewController.view belowSubview:tabBar];

-(void) didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
[(ViewControllerClass *)[viewControllers objectAtIndex:0] changeFrameSize:[NSNumber numberWithFloat:self.selectedViewController.view.bounds.size.width] height:[NSNumber numberWithFloat:self.selectedViewController.view.bounds.size.height]];
[(ViewControllerClass *)[viewControllers objectAtIndex:1] changeFrameSize:[NSNumber numberWithFloat:self.selectedViewController.view.bounds.size.width] height:[NSNumber numberWithFloat:self.selectedViewController.view.bounds.size.height]];
[(ViewControllerClass *)[viewControllers objectAtIndex:2] changeFrameSize:[NSNumber numberWithFloat:self.selectedViewController.view.bounds.size.width] height:[NSNumber numberWithFloat:self.selectedViewController.view.bounds.size.height]];
}

So because the selected view controller was always rotated and resized to the correct size, once it had rotated and adjusted i simply passed the same parameters to the sub views so they would resize too.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号