uiresponder

UIGestureRecognizer receive touch but forward it to UIControl as well

怎甘沉沦 提交于 2019-12-02 21:48:36
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) and B (red) are both subviews of the same superview (gray). In other words, they are both siblings and the order decides on which of them covers the other. Option 1: View B (red) has a regular UIButton as its subview. Option 2: View A (blue) has a regular UIButton as its subview. Given Option 1 for the sake of explanations: View A (blue) has a

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

≯℡__Kan透↙ 提交于 2019-12-02 18:02:19
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 responder objects to transfer responsibility for handling an event or action message to other objects in the application. If an object in the responder chain cannot handle the event or action, it resends the message to the next responder in the chain. The message travels up the chain, toward higher-level objects, until it is handled. If it isn't

Dismiss keyboard with swipe gesture (as in Message app)

依然范特西╮ 提交于 2019-12-02 15:50:06
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 process, the keyboard moves with it. Are Apple doing this with private APIs, or is there a way to control the keyboard like this from (I presume) a gesture recognizer? I created a UIView category that provides the desired functionality: https://github.com/danielamitay/DAKeyboardControl Edit: It has indeed been used on the app store. ma11hew28 The simplest

I can't create UIResponder nextResponder in Swift iOS

寵の児 提交于 2019-12-02 00:57:09
问题 I have a class ASTextField which extends after UITextField and I want to define textFieldResponder. Is any solution to write below line in Swift ?? UIResponder* nextResponder = [textField.superview viewWithTag:nextTag]; which has been written in Objective-C below? -(BOOL)textFieldShouldReturn:(UITextField*)textField; { NSInteger nextTag = textField.tag + 1; // Try to find next responder UIResponder* nextResponder = [textField.superview viewWithTag:nextTag]; if (nextResponder) { // Found next

I can't create UIResponder nextResponder in Swift iOS

只愿长相守 提交于 2019-12-01 22:37:12
I have a class ASTextField which extends after UITextField and I want to define textFieldResponder. Is any solution to write below line in Swift ?? UIResponder* nextResponder = [textField.superview viewWithTag:nextTag]; which has been written in Objective-C below? -(BOOL)textFieldShouldReturn:(UITextField*)textField; { NSInteger nextTag = textField.tag + 1; // Try to find next responder UIResponder* nextResponder = [textField.superview viewWithTag:nextTag]; if (nextResponder) { // Found next responder, so set it. [nextResponder becomeFirstResponder]; } else { // Not found, so remove keyboard.

Touches began in UITableViewController

本秂侑毒 提交于 2019-12-01 15:12:41
问题 I am defining this method in my UITableViewController subclass: - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { [super touchesBegan:touches withEvent:event]; NSLog(@"touch began"); } but it's not being triggered. UIViewController is a subclass of UIResponder so it should work, right? Thanks 回答1: Yep, that should definitely work. Make sure User Interaction Enabled is set for the view this controller corresponds to. If the view is loaded from a nib/xib, make sure File's Owner

UIMenuController with custom item not working with UICollectionview

亡梦爱人 提交于 2019-12-01 02:33:08
问题 I have added custom menu controller when long press on UICollectionViewCell [self becomeFirstResponder]; UIMenuItem *menuItem = [[UIMenuItem alloc] initWithTitle:@"Custom Action" action:@selector(customAction:)]; [[UIMenuController sharedMenuController] setMenuItems:[NSArray arrayWithObject:menuItem]]; [[UIMenuController sharedMenuController] setTargetRect: self.frame inView:self.superview]; [[UIMenuController sharedMenuController] setMenuVisible:YES animated: YES]; canBecomeFirstResponder Is

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

时间秒杀一切 提交于 2019-12-01 02:30:45
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 key, like there is for up, down, left, right, and escape (from UIResponder.h ): // These are pre-defined constants for use with the input property of UIKeyCommand objects. UIKIT_EXTERN NSString *const UIKeyInputUpArrow NS_AVAILABLE_IOS(7_0); UIKIT_EXTERN NSString *const UIKeyInputDownArrow NS_AVAILABLE_IOS(7_0); UIKIT_EXTERN NSString *const

keyboardWillShow called twice

点点圈 提交于 2019-11-30 19:35:26
I have a view with keyboard notifications such as keyboardWillShow and keyboardWillHide All the codes handles with the notification I use is taken from Apple's sample code "KeyboardAccessory" When I first enter this view, everything works fine. But when I return to this view from its subviews, every time I tap a button that says: [myTextField becomeFirstResponder]; the keyboardWillShow and keyboardWillHide methods will be called twice every time. It's really confusing, Could anyone helps me with this? really appreciate! You might want to post your code. If your methods are being called twice,

UITableViewCell skipped in responder chain

怎甘沉沦 提交于 2019-11-30 03:52:25
I'm attempting to trigger an event in a subview of a UITableViewCell , and let it bubble up the responder chain and be handled by a custom UITableViewCell subclass. Basically: SomeView.m (which is a subview of the UITableViewCell ) [self.button addTarget:nil action:@selector(someAction:) events:UIControlEventTouchUpInside] SomeCustomCell.m - (void)someAction:(id)sender { NSLog(@"cool, the event bubbled up to the cell"); } And to test why this wasn't working, I've added the someAction: method on the ViewController and the ViewController is the one that ends up handling the event that bubbles up