uitouch

UIScrollview getting touch events

牧云@^-^@ 提交于 2019-12-17 06:25:25
问题 How can I detect touch points in my UIScrollView ? The touches delegate methods are not working. 回答1: Set up a tap gesture recognizer: UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(singleTapGestureCaptured:)]; [scrollView addGestureRecognizer:singleTap]; and you will get the touches in: - (void)singleTapGestureCaptured:(UITapGestureRecognizer *)gesture { CGPoint touchPoint=[gesture locationInView:scrollView]; } 回答2: You can make your

Move UIImage only inside of another UIImage

冷暖自知 提交于 2019-12-14 03:52:38
问题 I have an UIImage which is shown in an UIImageView . I also have another image in an UIImageView which lays above the first image. I want to be able to drag the second image only within the borders of the first image. To make my goal a bit more clearer look at this image: . The green pin should be dragable but it should not be possible to drag the pin into the blue (outside of the map). At the moment the pin is dragable, but I don't know how to check if the pin is outside of the map. EDIT: I

Get historcial points ios

三世轮回 提交于 2019-12-13 04:26:43
问题 Is there any function or algorithm to catch all the points when drawing in iPhone ? Like in Android, where we have gethistoical points. 回答1: Check the methods touchesBegan:withEvent: , touchesMoved:withEvent: , touchesEnded:withEvent: and touchesCancelled:withEvent: to detect movements For example using the method -touchesMoved:withEvent: - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; CGPoint currentPosition = [touch locationInView

Mutlitouch drawing in iOS

Deadly 提交于 2019-12-12 01:05:51
问题 I am working with drawing project, and it is quite working well, the only problem is that, it works only with single touch.I want to do multitouch drawing, so that if user draws with his two fingers, then it should draw them Below is my code for single touch drawing -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; //LocationInView returns the current location of the reciever in coordinate system of the given View. m_previousPoint1 =

How can I detect a touch on an animated subview ? Or click an animated UIButton?

风流意气都作罢 提交于 2019-12-11 11:08:00
问题 I have a view that is moving. The view is sometimes on and sometimes off screen - it is twice the width of the screen. In this view, there are buttons that I need to be able to click. I've tried doing this in many ways already - using pure buttons using touches began on UIView I'm doing the animation using a CGPath in core animation Any help would be most appreciated Thanks 回答1: Whether the view is moving or not should irrelevent to the touch detection. If you have a UIButton object and are

iPad. UIBarButtonItem has an undocumented view of type UIToolbarTextButton. Huh?

限于喜欢 提交于 2019-12-11 06:56:22
问题 I have an iPad app where I have a view controller that is the UIGestureRecognizerDelegate for a number of UIGestureRecognizers. I have implemented the following method of UIGestureRecognizerDelegate: - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch { // Double tapping anywhere on the screen hides/shows the toolbar if ([gestureRecognizer isKindOfClass:[UITapGestureRecognizer class]] == YES) { if (touch.tapCount == 2) { self.toolbar.hidden =

Can I create a totally transparent UIView that receives touches?

坚强是说给别人听的谎言 提交于 2019-12-11 06:08:54
问题 I want to create a totally transparent UIView overlay (and it has subviews) to receives touches. I could set the alpha to a low value (like 0.02) to get an approximate effect. But I wonder is it possible for a alpha == 0 UIView to receives touches, through other UIView configs? 回答1: You can accomplish this by overriding the hitTest:withEvent: method in the class of your fully transparent view, like: - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event { return self; } The

Touch events (touchesMoved) not working on UIViews inside UIScrollView

前提是你 提交于 2019-12-11 02:16:47
问题 I have a UIView 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. UserInteraction is default ON of all 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! Many Thanks, 回答1: add the following code to implementation file then touches moved @interface UIScrollView(Custom) @end @implementation UIScrollView

How to register touches on a different view as a user drags their finger to a new one?

你说的曾经没有我的故事 提交于 2019-12-10 23:39:25
问题 So let's say I have a leftView and a rightView in my iOS app. Right now both views are independently registering touches. If I drag my finger from the leftView to the rightView, the leftView continues to register touches even though my finger is now in rightView. Unless I lift my finger up and touch the rightView again, rightView never registers a touch. Anybody have any ideas how to deal with this? 回答1: I had a similar issue a while back. This is covered in Event Handling Guide for iOS - Hit

iOS draw line with both arrow with start-end point while finger touch end and rotate from start or end point

亡梦爱人 提交于 2019-12-10 15:06:39
问题 I need help making a drawing demo. When the user draws a line using their finger, the line has directional arrows on both ends. When their finger releases, it draws the line with "?" (question-mark) in center of the line. Then, when user taps on the "?", it will show a new view and the user can enter a value, and the value is in that line. And we can add multiple lines on capture-image and also we can delete selected line. I don't understand how can I start developing these features so please