iOS - Show the animation/effect in runtime based on the guesture - ios

When we perform a gesture(pan, rotate, swipe...etc), usually we navigate page, scrolling, etc. The back end recognize the gestures, that's all. What I am searching is more on UI. How can I make the screen to provide visual feedback of the gesture I have just performed?
In other words, when user's finger is on the screen, example when
Swiping - one line displays on the screen, tab - one dot displays on the screen, rotate - two curve of lines display on the screen
Let me know if my question is not cleared enough.

This question is quite a big ask. There are lots of different elements to it.
Firstly you'll need to detect gestures: How to detect Swipe Gesture in iPhone SDK?
You can find some code here on recognizing simple gestures.
Once you can recognize gestures, you can change the UIImage contained in a UIImageView programmatically like this:
UIImage *myImage = [UIImage imageNamed:#"swipe_pic.png"];
[myImageView setImage:myImage];
You can read more about UIImageView here.
Hope this helps you.

Related

How to detect tap on small nearest buttons in iOS?

I need to build an app in which there is an image. On image there are many points where user can tap and depend upon that location of tap we need to take input. Tap locations are fixed.
User can zoom image. Detect multiple taps. (Single tap, double tap, etc.)
Biggest problem we are facing is there are too many points near to each other. So if we tap on one point we are getting other points clicked.
Following is the image according which I need to work on.
I need to detect tap on all red dots and take decision based upon that. That red dots will not be visible to user.
What I have tried is following.
Placed buttons on image as shown image. But problem is when user tap on button either button's tap event is not calling or it's not tapping right button which user seems to tap.
What I am thinking to do now is.
Taken image in scroll view then detect tap of scroll view and then based upon co-ordinates detect tap.
Is there any easier way to detect tap?
Your requirement is a pretty complex one.
Here you have to take a help of Core image. You need to process that image and get the core details of that image. Also "Morphological Operations" will help you to detect object from image. Take a look on links:
Core image processing
Morphological Operations

Dragging an uiview like facebooks menu slide

I know this has been probably asked before but I've seen many approaches and i don't know which is best for me, so plz don't send me a link to another post unless it addresses my problem directly.
I have a controller which has a uiview on the top (like a header) (this header is bigger than it seems because is partially hidden on top). on that view i have a uibutton which now with a touch up inside shows the entire header view and taping again returns it to its starting position (changing frame with animation). I want to also be able to drag the view but only changing position on the y axis(dragging up and down)... i was thinking of adding the dragInside/Outside event to the button but this doesn't give me the position of the finger... and also want to know when the user releases the drag so the view ends animation to any of its two possible states (showing or partially hidden). Is this a "touches began" , "touches moved" , "touches ended" thing? if it is please provide a code example. I also want to do this with another view but this is on the left side... same thing but this one moves on the X axis... any help is appreciated. or maybe it can be made with drag event if i only can save a CGpoint of last touch, maybe that's better, any other suggestions
Look at using a UIPanGestureRecognizer to detect the touch movements. Use the translationInView: of the gesture to set the view y position. The translation is the total movement since the start of the gesture so you don't need to remember and accumulate the offset position yourself.
The main thing to worry about while implementing this is bounding the y position of the view so that no matter how far the user drags the view won't go too high or low on the screen.
Use a UIPanGestureRecognizer, that's a class dedicated to handling such drag/pan gestures.
Everything is described here in Apple's documentation, including examples, so you should find your answer here.
There is also some sample code in Apple Developer Library that shows you how to use Gesture Recognizers if needed.

click on floor plan regions in an iPhone app?

I want to build an iPhone app that displays a floor plan of different regions/rooms. When a user taps on a region/room, it shows the hit-state color for a fraction of a second before sliding to a new UIView with additional text information.
Should I be setting up all the different regions via UIImages or should I draw my own floor plans programmatically? I tried drawing some rectangles programmatically, but wasn't sure if it's possible to attach tap event handlers to the graphics. Or if it's easier to maintain floor maps with unusual shapes programmatically.
My requirement was same like you. See my Question. Finally i am go ahead with UIScrollView with Zoom in out functionality. I have add multiple UIViews in Scroll and all UIViews have UILable So it will look like Room / Booth and it will look like this Question. To archive this i have face one Query and finally resolved this and implement the Floor Map Like my 1st question link.
Now to resolved your question that You have to implement UITapGestureRecognizer like below code.
UITapGestureRecognizer *fingerTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:#selector(handlefingerTap:)];
fingerTap.delegate = self;
[fingerTap setNumberOfTapsRequired:1];
than you have to set this Gesture to your view and implement the tap method like below
[rigionView addGestureRecognizer:fingerTap];
- (void)handlefingerTap:(UIGestureRecognizer *)gestureRecognizer
{}
If you have add multiple UIViews in Scroll than implement the above code in for loop.i have done the same.
I hope it will help you..

Animate a switch using an image sequence

I would like to know how to solve a problem I'm having. I have an image sequence that basically animates a switch.
I'd like to implement this in iOS. How would you advise me to go for that? Maybe using UIButton? Or rather UISwitch?
For a rather simple solution (tap switches, no swiping possible), I would advise you to use two UIViews stacked.
-1- At the bottom, use a UIImageView which allows you to run image animations.
-2- At the top, use a UIControl which will capture the touché-up-inside events.
Alternatively, you could use a UITapGestureRecognizer as a replacement for -2-. The latter option should only be considered if the resulting control will not be used for iOS < 3.2.
As soon as your tap-recognizer (UIControl or UITapGestureRecognizer) receives the tap-event, you simply play the animation provided through your UIImageView.
For more details on animations using UIImageView see its class reference, specifically on things like animationImages (an array of images).
As UIImageView does not provide you with a reverse animation feature, you will have to assign the images in the reverse order before animating back to the start (that is after a user switched it on and now switches back to off).
For a more complex solution (tap switches, swiping is possible), you may add a UISwipeGesture Recognizer to your custom control and use the status of that UIGestureRecognizer to select the currently visible image of your UIImageView.
iOS 5 allows you to make animated UIImages. You can put the animated UIImage right into the UIButton and animate it on button presses. Animated UIImage

Animate image like deleting Apps from iPad/iPhone

I have a ScrollView with several UIButtons (custom type). The UIButtons are shown as Images. I made it to subclass UIButton to shoot an event if the user taps on a button for a long time (approx. 3 seconds).
If a user tap's one of the subclassed UIButtons i thought about animating the selected UIButton the way the apps are animated if you want to delete them.
I have nearly no experiance with animations. Is there something somebody can point me to? All i've found was transitions, but thats not what i need.
(Ill rephrase) On SO, there are quite a few questions to answer this. One of then is this link How do you make images wobble like on the iPhone home screen?

Resources