Implement UITouches Gesture grammatically:
I want to implement touches gesture by xcode itself,
I looked iOS create touch event programmatically
but there is no answer.
If I am searching any wrong thing please let me know.
It's not easy to synthesize a touch event on the iPhone: you have to use undisclosed API, so you have a high probability of breaking on every update of the iOS and getting rejecting from Apple.
Here's a link that demonstrates how to synthesize a touch event on the iPhone:
Here's another question on StackOverflow: How to send a touch event to iPhone OS?
Related
I am trying to write an App for Apple tv4 (tvos). When my App starts, the view controller does receive touchesBegan events, as it should.
Without going into too many details, the App creates, moves, and deletes sub-views to respond to the user's interactions.
After a while, the view controller does not receive touchesBegan any more (this is the strange error that I am trying to debug).
Since I think the problem has something to do with the responder chain, I have made the following two experiments:
If I let the view controller override and return true from canBecomeFirstResponder, then the problem still occurs, but it occurs much less frequently.
If I do not override that function and instead check who is the first respnder, then I find that the App has no first responder, even before the strange error occurs. That is to say, the App has no first responder even when it is working properly!
Questions: What can prevent touchesBegan from being invoked? Is it related to the responder change? If so, please explain 2 above.
How exactly are you supposed to "touch" a view rendered on a non-touch screen enabled TV?
You're not.. tvOS doesn't work like iOS in the way that you cannot detect touches because there is no touch screen enabled input device supported on an Apple TV.
Instead, you use the UIFocusEngine to handle interactions with content presented within your view hierarchy.
Check out "Controlling the User Interface with the Apple TV Remote" from Apple's Developer Library for more information.
For the purposes of making app demos and presentations, I would like to draw circles corresponding to touches, just like in the iOS simulator, but on the device itself.
Ideally, this would be orthogonal to other code. Perhaps a UIView which draws the circles and forwards the events, but event forwarding seems to require the other views be aware:
http://developer.apple.com/library/ios/documentation/EventHandling/Conceptual/EventHandlingiPhoneOS/MultitouchEvents/MultitouchEvents.html#//apple_ref/doc/uid/TP40009541-CH3-SW17
Is there a clean way of doing this?
(I can't use the simulator for demos because my app uses gestures, MIDI, and OpenGL)
thanks!
There is a framework call fingertips which is available through cocoapods.
http://cocoapods.org/?q=on%3Aios%20fingertips
This will do what you are asking.
I don't think there's a clean way of doing this. However, this is what I would try:
Use method swizzling to hook up to all your views by swizzling the methods
- touchesBegan:withEvent:
– touchesMoved:withEvent:
– touchesEnded:withEvent:
for the UIView class. In addition, you may also need to swizzle some methods of UIGestureRecognizer subclasses, since they may prevent the methods listed above from being called. This way you can do your own thing (e.g. draw the touch points on the screen), and also let the views handle the touches as before.
If the user writes "t" on the particular touch area, the iPhone should recognise it and it should be displayed.
Where should the user write? Is there any specific area like UItextfield and how is it recoginised (letter written by the user)?
Apparently there is something that's called UITextField and you can access it's properties. But you should (TOTALLY) read through the developer.apple.com stuff first. There are also some nice videos on youtube and on apple that will help you get an entry.
Please! don't be lazy and learn about the basics! If you have any further questions about usage or something else: Use the Forum Search! Google it! Then ask your question!
You can subclass the UIVIew and create an new custom View.
Define the following methods:
touchesBegan:withEvent:
touchesMoved:withEvent:
touchesEnded:withEvent:
touchesCancelled:withEvent:
Each time user starts touching and ends the touch record the set of of points user has traveled and use these stored values in drawRect Method to draw lines between them.
Implement drawRect: method in your custom view and do the drawing of lines according to the users touch points.
You can also consider creating a gesture recognizer for this. This is the basic guide that can get you started.
Can i create custom touch events for iPhone?? will the device support for creating my own touch event handling ?
Take a look at the UIResponder class:
http://developer.apple.com/iPhone/library/documentation/UIKit/Reference/UIResponder_Class/Reference/Reference.html
You will probably want to implement the touchesBegan:withEvent:, touchesEnded:withEvent: and touchesCancelled:withEvent: methods. These will all be called with an NSSet of UITouches that you can do whatever you want with.
As of the 3.2 SDK there are UIGestureRecognizer classess. They do not play well with the older UIResponder calls, but if you can do 3.2 only they are easier to get going.
There are a number of handy subclasses, such as UIRotationGestureRecognizer for handling rotation.
If you are extending Apple classes like UIScrollView you must use gesture recognizers with 3.2 and later because when a gesture recognizer cancels it will cancel your UIResponder call tracking as well. If you are handling all the gesture tracking this is not an issue.
I am using iPhone sdk's motionended method to get the shake effect on 3.0.
The problem I am having is that the it works find on the first shake which I play a view, but once the video finished and I shake the device again it doesn't work.
Can anyone help me with this.
Thanks
Something else, like the video player, may have become the first responder after the first time you shake the device. This could be preventing the shake events from getting to your view or controller. You may need to manually restore the first responder status to the element handling the shake by sending it -becomeFirstResponder once the video has finished.