uiresponder

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

六月ゝ 毕业季﹏ 提交于 2019-12-17 16:43:10
问题 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 is also disabled for user interaction? What if we want to disable for just the main view but don't want to disable for the subviews? 回答1: You cant do that, Instead you would change the arrangment of your views like following: Main View-> subViews To

Responder Chain but NOT delegate property passes value back to view controller from container

ⅰ亾dé卋堺 提交于 2019-12-13 05:26:31
问题 The following code should show two ways to pass information from an embedded controller (UICollectionView) back to a detailed view controller using either the Responder Chain OR delegate approach. Both approaches use the same protocol, and delegate method. The only difference is if I comment out the delegate?.method line in didSelectItemAtIndex path, the Responder Chain works. BUT, if I comment out the Responder Chain line in the didSelectItemAtIndex method, the uncommentented delegate?

iPhone: Click view behind transparent UIScrollView

流过昼夜 提交于 2019-12-12 07:45:24
问题 I have a UIScrollView that is set to have a clear background. Part of the scrollview does have content, but part does not (so it shows other views behind it). I would like to be able to click through the UIScrollView and to the MKMapView behind, but only for the transparent portion of the UIScrollView. I have found some code which I am having a real hard time understanding how to get working: - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { if (![self

touchesEnded:withEvent: from UIScrollView First Responder

淺唱寂寞╮ 提交于 2019-12-11 23:51:39
问题 I've made a UIScrollView the first responder. I need to maintain touch events to a -touchesEnded:withEvent: method on a view behind it. I've tried using the -nextResponder method and that failed. I've tried forwarding -touchesEnded:withEvent: to the view behind it and that fails. How do I get this to work? The UIScrollView wont work unless it is the first responder or gets events some other way. Thank you for any help. Shame Apple's documentation and APIs are terrible in areas. 回答1:

CNContactViewController does something strange with responder chain

拟墨画扇 提交于 2019-12-11 12:42:59
问题 I am trying to implement UIKeyCommand shortcuts in my app, and for the most part, it seems to work fine. Except when I present CNContactViewController in a modal view, where it seems to do something strange: after the CNContactViewController is dismissed, the keyboard shortcuts still show in the discoverability HUD but stop working throughout the app, even if the presenting view controller manually calls becomeFirstResponder after the CNContactViewController was dismissed. This is from

iOS开发-关于UIResponder

心不动则不痛 提交于 2019-12-09 13:06:36
我们的App与用户进行交互,基本上是依赖于各种各样的事件。例如,用户点击界面上的按钮,我们需要触发一个按钮点击事件,并进行相应的处理,以给用户一个响应。UIView的三大职责之一就是处理事件,一个视图是一个事件响应者,可以处理点击等事件,而这些事件就是在UIResponder类中定义的。 一个UIResponder类为那些需要响应并处理事件的对象定义了一组接口。这些事件主要分为两类:触摸事件(touch events)和运动事件(motion events)。UIResponder类为每两类事件都定义了一组接口,这个我们将在下面详细描述。 在UIKit中,UIApplication、UIView、UIViewController这几个类都是直接继承自UIResponder类。另外SpriteKit中的SKNode也是继承自UIResponder类。因此UIKit中的视图、控件、视图控制器,以及我们自定义的视图及视图控制器都有响应事件的能力。这些对象通常被称为响应对象,或者是响应者(以下我们统一使用响应者)。 本文将详细介绍一个UIResponder类提供的基本功能。不过在此之前,我们先来了解一下事件响应链机制。 响应链 大多数事件的分发都是依赖响应链的。响应链是由一系列链接在一起的响应者组成的。一般情况下,一条响应链开始于第一响应者,结束于application对象

Passing touch events to appropriate sibling UIViews

為{幸葍}努か 提交于 2019-12-09 09:23:07
问题 I'm trying to handle touch events with touchesBegan in an overlay to a parent UIView but also allow the touch input to pass through to sibling UIView s underneath. I expected there would be some straight-forward way to process a touch event and then say "now send it to the next responder as if this one didn't exist", but all I can find is the nextResponder method which appears to be giving back the parent to my overlay view. That parent is then not really passing it onto the next sibling of

UIViewController with inputAccessoryView is not deallocated

萝らか妹 提交于 2019-12-09 06:14:26
问题 I have simple subclass of UIViewController (code below). If I attach inputAccessoryView, my viewcontroller is never deallocated. If I do not set inputAccessoryView in viewDidLoad, dealloc is called as expected. Am I missing something? @interface IMTestViewController : UIViewController @property (nonatomic, strong) UIView *messageInputView; @property(nonatomic, readwrite, strong) UIView *inputAccessoryView; @end @implementation IMTestViewController - (id)initWithNibName:(NSString *

Order of UIMenuItems in custom edit menu

烂漫一生 提交于 2019-12-08 12:05:39
问题 I want to add my own commands to the selection menu, but also keep the standard "copy", "cut", etc. commands. I use this: UIMenuItem *myItem = [[UIMenuItem alloc] initWithTitle:@"My Command" action:@selector(myCommand:)]; [[UIMenuController sharedMenuController] setMenuItems:[NSArray arrayWithObjects: myItem, nil]]; But this adds my command to the very end of the list in the edit menu. I want my command to appear first in it. How could I achieve this? 回答1: Solved it by myself. Here is what in

UIScrollView ignoring/passing on 3 touch

十年热恋 提交于 2019-12-08 06:32:17
问题 So I have looked over a bunch of other questions that could possible be duplicates. But none of the solutions that have been mentioned seem to work. Also, the answers tend to be scattered and incomplete. So, I have a UIView inside of a subclassed UIScrollView. All I need to do is have the UIScrollview ignore all forms of gesture that can occur with 3 fingers and, instead, pass it on to the UIView inside. Could someone help me with this. 回答1: You need to subclass the scrollview to accomplish