#iosdev iPad UISplitViewController QuickTip for shouldAutoRotateToInterfaceOrientation

I wasn’t having a problem, but I was just curious about the question of whether or not it was necessary to make all your shouldAutorotateToInterfaceOrientation:interfaceOrientation overrides jive when using a UISplitViewController.

Sure enough, as is mentioned here in this Stackoverflow thread:

All of your view controllers INSIDE the split view controller have to override [shouldAutorotateToInterfaceOrientation:interfaceOrientation]… To make it rotate to all orientations, return YES in all overrides.

Makes sense to me. Thanks to Krumelur.

#iOSDev Tip: Unblock events caused when adding subviews to your UIButtons

Recently, I was having an issue I was having with subviews added to my UIButton objects that I was customizing. The buttons would behave fine if they were standard rounded rect buttons, but the moment I added a UIView and some UILabels to it, the taps stopped responding.

But I was able to resolve it, thanks to the tip provided here:

iPhone: Subviews in UIButtons block the touch, unless…

The solution boils down to something very simple and it makes sense when you think about it, but at first it seems strange:

  • All you need to do is set userInteractionEnabled and exclusiveTouch to NO on the items that you want to add as subviews to your UIButton (and don’t set those properties to NO for the UIButton itself).

Once you turn off user interaction and exclusive touch properties on the subviews, your events will be sent to the underlying button (or at least that’s how I like to think of it happening…).

I initially read the post wrong and set them to YES and couldn’t figure out why it wasn’t working. Then I went back and looked at the comments, which pointed out where I went wrong.

Hope this helps!

///eks