Questions tagged [uiresponder]

The UIResponder class defines an interface for objects that respond to and handle events. It is the superclass of UIApplication, UIView and its subclasses (which include UIWindow). Instances of these classes are sometimes referred to as responder objects or, simply, responders.

The UIResponder class defines an interface for objects that respond to and handle events. It is the superclass of UIApplication, UIView and its subclasses (which include UIWindow). Instances of these classes are sometimes referred to as responder objects or, simply, responders.

There are two general kinds of events: touch events and motion events. The primary event-handling methods for touches are touchesBegan:withEvent:, touchesMoved:withEvent:, touchesEnded:withEvent:, and touchesCancelled:withEvent:. The parameters of these methods associate touches with their events—especially touches that are new or have changed—and thus allow responder objects to track and handle the touches as the delivered events progress through the phases of a multi-touch sequence. Any time a finger touches the screen, is dragged on the screen, or lifts from the screen, a UIEvent object is generated. The event object contains UITouch objects for all fingers on the screen or just lifted from it.

iOS 3.0 introduced system capabilities for generating motion events, specifically the motion of shaking the device. The event-handling methods for these kinds of events are motionBegan:withEvent:, motionEnded:withEvent:, and motionCancelled:withEvent:. Additionally for iOS 3.0, the canPerformAction:withSender: method allows responders to validate commands in the user interface while the undoManager property returns the nearest NSUndoManager object in the responder chain.

In iOS 4.0, UIResponder added the remoteControlReceivedWithEvent: method for handling remote-control events.

259 questions
84
votes
10 answers

UIGestureRecognizer blocks subview for handling touch events

I'm trying to figure out how this is done the right way. I've tried to depict the situation: I'm adding a UITableView as a subview of a UIView. The UIView responds to a tap- and pinchGestureRecognizer, but when doing so, the tableview stops…
andershqst
  • 1,454
  • 1
  • 14
  • 24
76
votes
7 answers

How to ignore touch events and pass them to another subview's UIControl objects?

I have a custom UIViewController whose UIView takes up a corner of the screen, but most of it is transparent except for the parts of it that have some buttons and stuff on it. Due to the layout of the objects on that view, the view's frame can cover…
Chris C
  • 3,221
  • 1
  • 27
  • 31
53
votes
5 answers

InputAccessoryView docked at bottom

I'm trying to achieve similar positioning behavior as the bottom text input bar in Apple's Messages app. I have tried many approaches, searched high and low and there are many similar questions but none have been satisfactory. To specify: There is…
47
votes
4 answers

Is there any way of asking an iOS view which of its children has first responder status?

In Mac OS X, you can find the first responder like this: [[self window] firstResponder] Is there any way of doing it in iOS? Or do you need to enumerate the child controls and send an isFirstRespondermessage to each one?
Tommy Herbert
  • 20,407
  • 14
  • 52
  • 57
42
votes
4 answers

How to get touches when parent view has userInteractionEnabled set to NO in iOS

When the parent view has userInteractionEnabled=NO, its subviews will not accept touch events even if their userInteractionEnabled property is set to YES. Is there any way to still get touch events in subviews?
subchap
  • 847
  • 2
  • 10
  • 15
38
votes
1 answer

UIGestureRecognizer receive touch but forward it to UIControl as well

How would you allow a UIGestureRecognizer of a UIView to receive a touch event but also make sure that another, underlaying/overlaying UIView also receives that very same touch event? Lets say I have got the following view-hierachie: Views A (blue)…
Till
  • 27,559
  • 13
  • 88
  • 122
36
votes
8 answers

Dismiss keyboard with swipe gesture (as in Message app)

When the keyboard is showing on the iPhone's Messages app, if the user begins a swipe down from the messages tableview and continues into the keyboard area, the keyboard will begin to dismiss. If they move their finger up and down during this…
Michael Stet
  • 361
  • 1
  • 3
  • 3
34
votes
4 answers

On iOS, if a superview's userInteractionEnabled is NO, then all subviews are disabled as well?

I thought when a view is touched or tapped on, its handler get called first, and then its superview's handler is called (propagate upward). But is it true that if the superview's userInteractionEnabled is set to NO, then all subviews and offspring…
nonopolarity
  • 146,324
  • 131
  • 460
  • 740
32
votes
2 answers

EXC_BAD_ACCESS tapping uisearchbar three times

I am trying to implement a search bar in a UICollectionView as a UICollectionViewReusableView This way I am not using a UISearchController but I am changing the datasource of the collectionview In my custom layout I am adding the searchbar this…
Phil Niedertscheider
  • 1,068
  • 11
  • 29
31
votes
5 answers

How do Responder Chain Works in IPhone? What are the "next responders"?

This is what the documentation says: If the first responder [to an event or action message] cannot handle an event or action message, it forwards it to the “next responder” in a linked series called the responder chain. The responder chain allows…
user4951
  • 32,206
  • 53
  • 172
  • 282
26
votes
3 answers

How to add tap gesture to UICollectionView , while maintaining cell selection?

Task Add a single tap gesture to UICollectionView, do not get in the way of cell selection. I want some other taps on the no-cell part of the collectionView. Code Using XCode8, Swift 3. override func viewDidLoad() { ... …
addlistener
  • 871
  • 1
  • 12
  • 20
25
votes
10 answers

UIButton in cell in collection view not receiving touch up inside event

The following code expresses my problem: (It's self-contained in that you could create a Xcode project with an empty template, replace the contents of the main.m file, delete the AppDelegate.h/.m files and build it) // // main.m // …
Aky
  • 1,777
  • 1
  • 14
  • 19
22
votes
12 answers

How to cancel a sequence of UITouch events?

I have a UIImage view that responds to touch events. I want to cancel the touch sequence, i.e., further calls to touchesMoved:, if the touch goes outside of certain bounds. How can I do that? I know that in touchesMoved: I can inspect the…
subjective-c
  • 1,833
  • 9
  • 25
  • 35
19
votes
6 answers

Why does AppDelegate inherit from UIResponder?

I noticed that when creating a new project with the iPhone Master-Detail template in Xcode 4.2 beta 4, it does: // AppDelegate.h @interface AppDelegate : UIResponder Why does AppDelegate inherit from UIResponder instead of…
ma11hew28
  • 121,420
  • 116
  • 450
  • 651
19
votes
1 answer

How can I make a UIKeyCommand with the return/enter key?

I'd like to make a UIKeyCommand that uses only the [return] key. So far I've tried: UIKeyCommand *selectCommand = [UIKeyCommand keyCommandWithInput:@"\n" modifierFlags:0 action:@selector(chooseSelection:)]; There's no global constant for the enter…
paulrehkugler
  • 3,241
  • 24
  • 45
1
2 3
17 18