Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 7 When Rotating View in Tab Bar, Right Side of View is Not Clickable

I have a very simple app consisting of a single view. Everything works fine, the app rotates and buttons on the right side of the screen are clickable. I'm using iOS 7 and Xcode 5.

If I go into the storyboard and select the view then do Editor > Embed In > Tab Bar Controller, now when the app rotates from portrait to landscape, the right side of the app is not clickable. It seems to be exactly 768 pixels from the left where it stops working, so it makes me think there's something in the app that didn't rotate. What could be wrong?

It's just a basic single view wizard app that I put some UI elements on it to test. The only thing that makes it stop working is embedding in the tab bar.

Here is the whole project: https://github.com/tomkincaid/rotate

Update: I had originally used the same iPhone storyboard for both iPhone and iPad and thought this might be the issue. However, I created a new iPad storyboard and it has the same issue.

Another Update: If I put the view inside a navigation controller, it works. So View works and Tab>Nav>View works, but Tab>View doesn't work.

enter image description here

like image 461
Tom Kincaid Avatar asked Sep 20 '13 18:09

Tom Kincaid


4 Answers

I had the same problem. Putting the following code in my view controller's viewDidLoad fixed it:

self.view.autoresizesSubviews = YES;
self.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
like image 62
Josh Adams Avatar answered Nov 09 '22 23:11

Josh Adams


Just put the following code in you TabBarViewController class.

- (void)viewDidLayoutSubviews
{
    // fix for iOS7 bug in UITabBarController
    self.selectedViewController.view.superview.frame = self.view.bounds;
}
like image 24
Slavcho Avatar answered Nov 09 '22 22:11

Slavcho


To elaborate this answer, you can achieve the same result by editing the source code of the storyboard.

Replacing

<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>

with

<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>

for the view of the view controller that causes the problems.

like image 31
Sulthan Avatar answered Nov 09 '22 22:11

Sulthan


In the list of view controllers on the left hand side navigate to the views/view controllers affected, drag the view to underneath the first responder so that it is disassociated to the view controller's view.

Then go to the layout tab on the right hand side, select all 4 anchors and both sets of resizing arrows (horizontal + vertical).

Then drag the view back to where it was originally (just below the view controller).

like image 28
James Newbould Avatar answered Nov 09 '22 23:11

James Newbould