uiresponder

How to effectively process UITouches in a multitouch sequence

一曲冷凌霜 提交于 2020-01-19 04:04:38
问题 I am working with multitouch while writing, So basically what I am doing is, I am writing with hand support, because typically, its how user writes, I followed this link How to ignore certain UITouch Points in multitouch sequence Everything is working fine with single touch, but their is some problem when I write with my hand touching the screen i.e multiple UItouches Below is my code In touches began, I go through all touches and I find the touch with highest y position, below is my code

How to copy selected data from a PDF displayed in a UIWebView

好久不见. 提交于 2020-01-14 06:21:04
问题 I am working on a project that displays a PDF in a UIWebView. I have added another UIMenuItem to the UIMenuController in order to do various things with the text in the UIWebView that has been selected. The problem is that I am not able to access the selected text in my newly created selector method. If I use the copy command on selected text first, then I can get that previously copied text from the pasteboard, but a command like [myWebView copy:sender]; called from my new selector does

How to cancel a sequence of UITouch events?

痴心易碎 提交于 2020-01-10 02:28:47
问题 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 coordinates of the touch object and ignore it, but what I don't know is how to cancel the sequence altogether. I don't see any method documented in the Apple Developer UIResponder Reference that I can call to cancel a touch sequence. 回答1: This solution may

How to disable popup menu items like Select, Select All, Suggest…, Define (on UIWebView)?

风流意气都作罢 提交于 2019-12-31 03:59:34
问题 How to disable popup menu items like Select , Select All , Suggest... , Define (on UIWebView )? I have found the following information on the help but don't understand how to use it: For the editing menu commands, this is the shared UIApplication object. Depending on the context, you can query the sender for information to help you determine whether a command should be enabled. 回答1: Swizzle the following method: #import "NSObject+myCanPerformAction.h" @implementation NSObject

UIResponder and multiple UIControlEvents

北战南征 提交于 2019-12-24 00:25:45
问题 Is there a way to call a selector for multiple UIControlEvents? this doesn't work, but itl'll give u an idea of what i'm trying to do. [self.slider addTarget:self action:@selector(sliderDidStopDragging:) forControlEvents:UIControlEventTouchUpInside, UIControlEventTouchUpOutside]; thanks!! 回答1: try this way instead: // same selector for different events [self.button addTarget:self action:@selector(selector0:) forControlEvents:UIControlEventTouchUpInside]; [self.button addTarget:self action:

Determine if responder chain will handle an action

倖福魔咒の 提交于 2019-12-23 13:22:39
问题 The responder chain is cool. Particularly, being able to send custom actions to the first responder that will bubble up to anyone else that might be interested: [[UIApplication sharedApplication] sendAction: @selector(commandToSend) to: nil from: self forEvent: nil] . Or less custom actions with: [[UIApplication sharedApplication] sendAction: @selector(resignFirstResponder) to: nil from: self forEvent: nil] I'd like to know – is there a way to test before hand if a particular action from a

Moving keyboard when editing multiple textfields with constraints swift

笑着哭i 提交于 2019-12-23 05:29:10
问题 I have UIViewController which looks like this: I set all the relevant constraints . I'm trying to shift the UIView up when the keyboard shows up - when I click on the UITextfields below. I have the following code: static func addRemoveKeyboardObserver(addObserver: Bool, keyboardMargin: CGFloat, view: UIView?) { Utils.keyboardMargin = keyboardMargin Utils.heightChangingView = view if addObserver { NotificationCenter.default.addObserver(self, selector: #selector(Utils.keyboardWillChange

nextResponder in Swift 3

孤人 提交于 2019-12-22 00:13:39
问题 in Swift 2 this code works fine override func nextResponder() -> UIResponder? { // it's called when user make any touch event return super.nextResponder() } it's basically helps to get notification about any user interaction. in Swift 3 now it's a variable not a function and I can't even observe it with didSet. so how to use the code above in Swift 3 回答1: You can override the variable: override var next: UIResponder? { get { // do something return super.next } } As the variable is defined as

UIGestureRecognizer receive touch but forward it to UIControl as well

◇◆丶佛笑我妖孽 提交于 2019-12-20 10:18:37
问题 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

Perform copy/cut from UIResponderStandardEditActions

让人想犯罪 __ 提交于 2019-12-18 07:16:10
问题 These are standart actions for UIMenuController declared http://developer.apple.com/library/ios/#documentation/uikit/reference/UIResponderStandardEditActions_Protocol/UIResponderStandardEditActions.html How can I perform these methods manually, like from another UIMenuItem or whatever? I can't find the right selector:( [self cut:sender]; [UIResponder cut:sender]; [[UIMenuController sharedMenuController] cut:sender]; (void) cut: (id) sender {[super cut:sender];} So far non of these don't work,