zkwentz
zkwentz

Reputation: 1105

iOS AutoLayout Storyboard Landscape Orientation UIButton doesn't accept touch

I have a Tab Bar Application, the first view controller has a settings UIButton in the top right hand corner. When you rotate to landscape mode, it doesn't accept touch events. Rotate to portrait it does. Switch view controllers, and switch back. Everything works fine in both orientations.

Interestingly, the UITableView that's also on the right hand side in landscape mode, seems to only accept touch events on a certain portion of it. If I move the settings UIButton to just outside that portion, it works as expected, even without switching view controllers. (I know what you're thinking, something is above it. As far as I can tell nothing is, I have changed all the views and subviews to have a different background, and nothing is out of place or not as expected.

I'm including the settings for all the relevant components...

TabBarViewController Attributes

enter image description here

FirstViewController Attributes

enter image description here

Containing view attributes that Settings UIButton is a child of

enter image description here

Containing view metrics that Settings UIButton is a child of

enter image description here

Settings UIButton Attributes

enter image description here

Settings UIButton Metrics

enter image description here

Settings UIButton Connections

enter image description here

Z-Order of Elements in FirstViewController

enter image description here

I've opened a new TabBar project and tested it, and everything works fine there. It seems like something is over the right side, but nothing appears to be.

Upvotes: 0

Views: 1058

Answers (2)

Nico
Nico

Reputation: 11

Add the following line to the viewDidLoad method of your controller:

[self.view setAutoresizingMask:UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight];

Another thing, to look for overlapping views, use the color blended layers option in the debug menu of the simulator.

Upvotes: 1

Kumar Aditya
Kumar Aditya

Reputation: 1097

Problem is 'frame not set' of your view or view controller. You need to check, your view/viewcontroller's frame is not getting change when you change the orientation. SubViews will show as per their positon , but I am pretty sure that their parentview's frame is not according to landscape mode that is why your table is also not responding. Try to set its bound as view's frame when orientation changes.

Upvotes: 1

Related Questions