in my app, I want users only use one finger to touch the ipad, it means, when you touch the screen, others touches won't respond events......
any helps?
try disabling multitouch throug IB or through code.
keep a track of count of touch, and then implement it accordingly.
Related
I know that you can use a UITapDetector to detect any time the screen is tapped. But, is there a way to detect any time the screen is simply touched? Long, short, whatever, the finger doesn't even have to come up again, just any time the screen is touched at all, have something happen.
Yes, implement UIResponder touchesBegan(_:with:) and related methods. Now you are receiving the raw touches (not completely raw, since they are still associated with the hit-test view); and you can interpret or respond to them however you like. That's how you'd implement a drawing app, for example.
That in fact is what we used to have to do for all touches, before gesture recognizers were invented.
I am trying to add a touch to UIButton.
I want it to be when I click on button, until I release the finger, it won't click on it.
I Have played with many touch events, Touch down, Touch up inside etc but none is working like that. This is a very common touch event. How can I add such a thing in iPhone UIButton?
Touch up inside will only execute when you remove your finger from the button
Touch down event will work as soon as you touch the button.
Sample Project:
https://www.dropbox.com/s/hm82u553ktyszbd/ST-16385963.zip
Touch up inside is the event you should use here. If it doesn't work, that means you haven't implemented it correctly.
Could you post your code? It sounds like you want the Touch Up Inside functionality of not firing until the finger is raised.
I made a slideview using a uiview and detecting touches to move pages. This slideview is almost like this, except that I made it works like a UITableView.
Now I'm using this to uivews with uiscrollviews. The problem is, "how to distribute touch events to scrollview or slideview?". I had the logic to do. Basically, the uiscrollviews are vertical and slideview is horizontal.
I tried hitTest to keep the touchBegan,Moved,Ended in slideview. When I get a touch movement horizontally, I keep to slideview, when vertically, distribute to uiscrollview. But I cannot figure out how to distribute events to uiscrollview.
Calling [scrollView touchesBegan:touches withEvent:event] doesn't work. I supposed uiscrollview has a different way to work.
If you don't find a clue to your answer, probably, you're wrong.
UIScrollView uses a own way to get touchesBegan, Moved and Ended. Way that I don't, but it's mean if you override touchesBegan to make UIScrollView stops to work, you won't get it. Using hitTest in superview of scroll, you can get the touches before UIScrollView but you can't change the touches target while touches is happening.
After all, there is one way to solve this, ashly, three ways.
1- Simulate touches
I didn't test this, you'll know below. Events come from UIWindow and distributed to subview by - (void)sendEvent:(UIEvent *)event. We don't know how touches target is saved, and change this is completely out of question. But we can use the idea of override superview's hitTest to know what the user will do to make a 'WA' to change the target. To do this, simulate a event of touch ended. Supposed target will be reset. Simulate a event of touch begin again, and this time make sure to let hittest get scrollview.
You can find how simulate events here. The problem is, probably your app will be rejected due using private methods.
2- Make your own UIScrollView
This should be the best or the worst, depending what you want to do. I believe it's painful. And isn't what you want to do right now.
3- Surrender to 'Nest UIScrollView'
To make slideshow of pdf, hq, docs and books, it's the best and painless way. Put a UIScrollView inside another and let them reach an agreement of scrolling. http://developer.apple.com/library/ios/#documentation/WindowsViews/Conceptual/UIScrollView_pg/NestedScrollViews/NestedScrollViews.html
i'm developing a application for gestures recognizer for iPad and i want to disable the default gesture recognizer of the iOS. When i ask a way do disable the gestures recognizer is using my own application, so i need a way using some functions of the api and not using the settings way.
I don't completely understand your question.
You can add UIGestureRecognizer to objects. You can also remove them.
- (void)removeTarget:(id)target action:(SEL)action
For example:
[imageView addGestureRecognizer:singleTap];
[imageView removeGestureRecognizer:singleTap];
The four- and five- finger gestures are not officially part of iOS, and may never be.
Though it would be best to figure out an alternative, you should be able to use these gestures for now and not fear conflicts (save on the iPads of developers who have specifically turned on this feature, whose users know that said features may conflict with apps.)
One alterative is to change your design to avoid 4-5 finger swipe. From what i know, the 4-5 gesture setting is for end-users to return home screen/open up multitasking bar and you can't do anything about it till Apple releases it for developer, right now it's still on the stage of experimenting for end users.
You can use a UITapGesture and set the number of touches in the Attribute Inspector if you want multiple touches. Doesn't this do what you want?
when you go to gestures in the assistive touch menu, to disable it you swipe to the right like you would to delete a song or a note.
For my iPhone game I wrote the entire thing in OpenGL ES, and now I'm trying to overlay a TextView to display a scoreboard. The problem is now my touch input doesn't work correctly, because the Textview is recieving the touch input rather than my opengl view. Is there a way I can just disable touch interactions on the textview?
Found the answer, in case anyone else runs in to this:
[textView setUserInteractionEnabled:false];
It does in fact send touches to the things behind it.
UIView should have a property that you can set to enable or disable touch interactions, now will it make it so the text view is no longer in the way and the view underneath it will pick up touch events? I dont know youll have to check :)