uitouch

Keep two MKMapViews showing the same region

喜夏-厌秋 提交于 2019-12-04 04:33:02
问题 On my iPad app, I have 2 mapViews that are the same size displayed next to each other. I want these to always show the same area. I achieve this now using the regionDidChangeAnimated: delegate method. This does not always work that great (sometimes the regions are different after zooming) and there is a lag between the user moving one of the maps and the other one moving. Is there a good way to duplicate the touches across both maps so that as a user is panning and zooming on one, it will

How to “transfer” first responder from one UIView to another?

谁说我不能喝 提交于 2019-12-03 21:47:43
问题 I have a UIView subclass ( CustomView for purposes of this question) that has its own handling of all touches events (Began, Moved, Ended, Cancelled). I also have a UIButton that is a sibling of CustomView that overlaps it. For example, my view hierarchy looks like this: UIView (Controller's view) CustomView with frame (0, 0, 300, 300) UIButton with frame (0, 0, 100, 50) I would like the CustomView to capture touch events once the user has dragged out of the UIButton. Through debug logging,

Touch events not working on UIViews inside UIScrollView

不打扰是莪最后的温柔 提交于 2019-12-03 17:13:35
I have a series of UIViews inside a UIScrollView, and the UIViewControllers for those views are not receiving the touch events. If I take the views out of the scroll view then it works. I have enabled userInteraction on the views but it's still not working! This must be possible and I'd be really grateful if someone could point me in the right direction! Thanks, Mike Do the views have their own touch handlers, or are you relying on the viewcontroller to get the touches? Depending on how you have set things up, the views may be handling the touches without passing through to the view controller

UITouch touchesMoved Finger Direction and Speed

回眸只為那壹抹淺笑 提交于 2019-12-03 16:48:30
问题 How can I get Speed and Direction of finger movements in touchmoved function? I want to get the finger speed and finger direction and apply it in a UIView class direction movement and animation speed. I read this link but I can not understand the answer, in addition it is not explaining how I can detect the direction: UITouch movement speed detection so far, I tried this code: -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *anyTouch = [touches anyObject]; CGPoint

timestamp and calculating velocity of a swipe

久未见 提交于 2019-12-03 16:14:40
Hey I know there are already a few posts about this - yet I still can't find an adequate answer for the problem I'm having. Just new to cocoa and iOS, I'm in the middle of developing my first iOS game. In this game I would like to be able to calculate the speed of a user's swipe. I'm having no difficulty finding the distance between successive touches in the swipe motion, but am having difficulty determining the time elapsed between the touches in touchesMoved: I do calculations with the current touch as well as keep track of the last previously recorded touch as a UITouch in touchesEnded: I

How to get current touch point and previous touch point in UIPanGestureRecognizer method?

本小妞迷上赌 提交于 2019-12-03 12:41:26
I am new to iOS, I am using UIPanGestureRecognizer in my project. In which I have a requirement to get current touch point and previous touch point when I am dragging the view. I am struggling to get these two points. If I use touchesBegan method Instead of using UIPanGestureRecognizer , I could get these two points by the following code: - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ CGPoint touchPoint = [[touches anyObject] locationInView:self]; CGPoint previous=[[touches anyObject]previousLocationInView:self]; } I need to get these two points in UIPanGestureRecognizer

Getting the UITouch objects for a UIGestureRecognizer

戏子无情 提交于 2019-12-03 11:40:21
问题 Is there a way to get the UITouch objects associated with a gesture? UIGestureRecognizer doesn't seem to have any methods for this. 回答1: Jay's right... you'll want a subclass. Try this one for size, it's from one of my projects. In DragGestureRecognizer.h: @interface DragGestureRecognizer : UILongPressGestureRecognizer { } - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event; @end @protocol DragGestureRecognizerDelegate <UIGestureRecognizerDelegate> - (void) gestureRecognizer:

A count of started touches is not equal to count of finished touches

南楼画角 提交于 2019-12-03 06:00:44
I have the following code for testing purposes: - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { [self customTouchHandler:touches]; } - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { [self customTouchHandler:touches]; } - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { [self customTouchHandler:touches]; } - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event { [self customTouchHandler:touches]; } - (void)customTouchHandler:(NSSet *)touches { for(UITouch* touch in touches){ if(touch.phase == UITouchPhaseBegan) touchesStarted++;

When touches Cancelled method get invoked in iPhone?

混江龙づ霸主 提交于 2019-12-03 05:50:19
I am able to understand that when user just touches the view, touches Began and Ended called. When user swipes their hand on a view, touches Moved method gets called. But when does touches Cancelled get called or by what action on user this method gets called? I think probably the most common reason for touchesCancelled being called (since iOS 3.2 anyway) is following the recognition of a gesture by a UIGestureRecognizer. If your view has any kind of gesture recognizer attached to it then it is often very important to provide a custom implementation of the touchesCancelled method - note this

Getting the UITouch objects for a UIGestureRecognizer

和自甴很熟 提交于 2019-12-03 02:08:36
Is there a way to get the UITouch objects associated with a gesture? UIGestureRecognizer doesn't seem to have any methods for this. Jay's right... you'll want a subclass. Try this one for size, it's from one of my projects. In DragGestureRecognizer.h: @interface DragGestureRecognizer : UILongPressGestureRecognizer { } - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event; @end @protocol DragGestureRecognizerDelegate <UIGestureRecognizerDelegate> - (void) gestureRecognizer:(UIGestureRecognizer *)gr movedWithTouches:(NSSet*)touches andEvent:(UIEvent *)event; @end And in