uiresponder

UIResponder Troubles

无人久伴 提交于 2019-12-08 03:04:27
问题 Tonight I've been battling with UIResponder. Here's my predicament. If I put in - (BOOL)canBecomeFirstResponder{ return YES; } to my mainViewController then I can get shake events.. - (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event { if (event.type == UIEventSubtypeMotionShake) { //do something } } However, this means that when I call things like mail forms and webviews, the keyboard does not show up. Is there any way I can get both shakes working and keyboard working in

UIResponder 对象详解

蹲街弑〆低调 提交于 2019-12-07 20:58:10
在 iOS 中,一个 UIResponder 对象表示一个可以接收触摸屏上的触摸事件的对象,通俗一点的说,就是表示一个可以接收事件的对象。 iOS 中,所有显示在界面上的对象都是从 UIResponder 直接或间接继承的。 下面是 UIResponder 类的一些定义信息: 触摸事件相关: 方法名称 说明 touchesBegan:withEvent 当用户触摸到屏幕时调用方法 tochesMoved:withEvent 当用户触摸到屏幕并移动时调用此方法 tochesEnded:withEvent 当触摸离开屏幕时调用此方法 tochesCancelled:withEvent 当触摸被取消时调用此方法 运动事件相关: 运动事件是指当用户以特定方式移动设置,如摇摆设置时,设置会产生运动事件,由以下几个方法进行处理: 方法名称 说明 motionBegan:withEvent 运动开始时执行 motionEnded:withEvent 运动结束时执行 motionCancelled:withEvent 运动被取消时执行 响应对象链相关: 方法名称 说明 isFirstResponder 指示对象是否为第一响应者,这里的第一响应者就是当前有焦点的对象,叫法挺奇怪的,第一次看到真还难以理解这个叫法所表达的意思 nextResponder 下一个响应者,在实现中,一般会返回父级对象

How to send touch events to nextResponder in Swift

非 Y 不嫁゛ 提交于 2019-12-07 12:06:59
问题 Background I'm trying to make a UICollectionViewCell behave like a button (ie, do an animated dim on touch). I had the idea of just filling the cell with a UIButton . The button would then take care of the visual effect of being tapped. But then I would need to pass the touch event on to the parent (the UICollectionViewCell ) so that the button does not just consume the event. That way I could handle it with the collection view's didSelectItemAtPath . The problem below is my attempt to figure

Detecting a touch anywhere on the screen

倖福魔咒の 提交于 2019-12-07 08:49:25
问题 I am wanting to know when a user has touched anywhere on the screen of my app. I have looked into using -(UIResponder *)nextResponder but unfortunately this will not work, as I am also reloaded a table automatically, so this gets trigged when that occurs. I have also tried a gesture recognizer, with the following code. But this will only recognise touches on the view. Where as I have many buttons the user will be using to operate the app. I would like to avoid adding a gesture recogniser or

SpriteKit SKScene missing touchesEnded

不羁岁月 提交于 2019-12-06 21:33:41
问题 I've noticed that touchesEnded don't always get delivered to an SKScene on multi touch. Depending on speed of removing fingers etc, I would permanently miss some of the touchesEnded. touchesCancelled is implemented and I added a custom UIView and put over the left side of the screen - no problems. I made a custom SKView and captured events - again no problem. It's obvious that SKScene doesn't get all the touchesEnded the SKView it's embedded in, but why? (BTW, I'm running the SKScene

UIResponder Troubles

≯℡__Kan透↙ 提交于 2019-12-06 09:37:01
Tonight I've been battling with UIResponder. Here's my predicament. If I put in - (BOOL)canBecomeFirstResponder{ return YES; } to my mainViewController then I can get shake events.. - (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event { if (event.type == UIEventSubtypeMotionShake) { //do something } } However, this means that when I call things like mail forms and webviews, the keyboard does not show up. Is there any way I can get both shakes working and keyboard working in modal views? I've tried adding [self resignFirstResponder]; in -viewDidDissapear, which gets called when

How do I add the UIApplicationDelegate to the end of the UIResponder chain?

跟風遠走 提交于 2019-12-06 02:58:39
问题 I'm trying to provide an IBAction method for common functionality that is required at various parts of the app. i.e. Login is implemented modally, and if it succeeds results in a notification that allows all loaded view controllers to react to this event (transition from anonymous to authenticated) @interface MyAppDelegate : NSObject <UIApplicationDelegate> { ... } - (IBAction)loginTapped:(id)sender; @end I set the action of that button to the First Responder in IB, however the responder

How to send touch events to nextResponder in Swift

匆匆过客 提交于 2019-12-05 23:34:05
Background I'm trying to make a UICollectionViewCell behave like a button (ie, do an animated dim on touch). I had the idea of just filling the cell with a UIButton . The button would then take care of the visual effect of being tapped. But then I would need to pass the touch event on to the parent (the UICollectionViewCell ) so that the button does not just consume the event. That way I could handle it with the collection view's didSelectItemAtPath . The problem below is my attempt to figure out how to pass the event on. My problem I came across this Objective-C answer for passing the touch

Detecting a touch anywhere on the screen

穿精又带淫゛_ 提交于 2019-12-05 19:04:33
I am wanting to know when a user has touched anywhere on the screen of my app. I have looked into using -(UIResponder *)nextResponder but unfortunately this will not work, as I am also reloaded a table automatically, so this gets trigged when that occurs. I have also tried a gesture recognizer, with the following code. But this will only recognise touches on the view. Where as I have many buttons the user will be using to operate the app. I would like to avoid adding a gesture recogniser or code for this in every button and segment control I have on the screen UITapGestureRecognizer *tap = [

SpriteKit SKScene missing touchesEnded

China☆狼群 提交于 2019-12-05 03:36:18
I've noticed that touchesEnded don't always get delivered to an SKScene on multi touch. Depending on speed of removing fingers etc, I would permanently miss some of the touchesEnded. touchesCancelled is implemented and I added a custom UIView and put over the left side of the screen - no problems. I made a custom SKView and captured events - again no problem. It's obvious that SKScene doesn't get all the touchesEnded the SKView it's embedded in, but why? (BTW, I'm running the SKScene completely without any nodes) EDIT: Some further investigation reveals I can get SKScene to lose a touch