Here's a couple of things that tripped me up today while developing an iOS app:
1. Views Blocking TouchesIf you drag a plain view onto your view controller in storyboard, it will stop all touches reaching views located underneath. You will need to ensure the User Interaction Enabled setting is unchecked if you want your touches to be passed through.
2. Tap and Drag Location Tracking
Storyboard lets you easily wire up your buttons to methods in your view controller that get called whenever a user taps or drags inside the button. If you use Storyboard to create the stub method for you by dragging in the connection to an empty space in your view controller, it will create a method like:
However, you may want to know where the user touched. Fortunately, this is easily available - just ensure you select the Sender and Event option in the Arguments drop-down when create the connection in Storyboard. This will then auto-create a method in your header file like:
You can then get the touch position with the following code:
- (IBAction)editClicked:(id)sender forEvent:(UIEvent *)event;
NSSet *touches = [event allTouches]; UITouch *touch = [touches anyObject]; CGPoint pointTouched = [touch locationInView:self.view];