NSImageView and NSUndoManager - iphone

I have a image on the view and user can drag and move the image or rotate the image with finger touch.
I want to do Undo the action performed by user.
Like if the image is move to new location and then user press undo button, image should move back to the previous location. Or if user rotates the image and then press undo button it should rotate image to its previous angle.
It would be helpful if I get any sample example for the same.
Thanks in advance

Check out the Solution that Rob Posted here.
It only deals with one gesture at a time though. If you are dealing strictly with the Transform and the Center (for Pan) then You should be fine with his solution if you do not allow Pan, Rotate, Pinch at the same time. If Pinch Pinch and Rotate at the same time, if working with a Transform you just need to set the transform once at the beginning and deal with who sets it first so the other gesture does not set the Original Transform.
I'm working on a way to encapsulate multiple attributes into a Dictionary to then Undo/Redo, though need a way to copy that Dictionary to the Undo/Redo Stack, see this Question

Related

Modifying smooth curve with Anchor points

I wish to emulate this effect in Xcode with Swift. After some research I managed to find some articles about drawing smooth curves using a set of points .But I am still unclear about how I could to dynamically modify curves when the user touches/holds the screen.
Question :
I know how to make a smooth Bezier curve, but how can I add gesture recognizers such that by dragging the curve its shape changes.
I only need someone to point me in the right direction. Is there a guide or article in particular that could be useful?
Create transparent ControlPointView for every control point of the curve with a size of 50*50pt, so that users can easily tap them and drag.
Add a small image in the middle of every ControlPointView, so that users can see where the control point is located.
Add UIPanGestureRecognizer on every ControlPointView and handle it in view controller.
Use centers of control points to rebuild UIBezierPath every time gesture recognizer's state is changed.

Looking to mimic the iPhone lock screen camera drag

I've been searching and searching on how apple makes the dragging motion on the lock screen to open the camera so clean. I'm trying to do a similar thing with an app where you drag from the bottom up to reveal a menu, but i cant quite get it right. Anyone know how to, or of any tutorials that show how to do this? Thanks in advance!
To follow up what's been mentioned by Hejazi I believe you can achieve this in 3 steps:
create a background rectangle with some corner radius (this is a property of CGRect).
create a top view, corresponding to the part you want to be able to slide. Attach a pan gesture to this view so you will be able to handle the animation for this view.
for the text part being highlighted I think you need another two views: I will apply a mask corresponding to the text to a view so you get some transparency only for the letters of your text and animate a white round view behind it.

how can i animate image that moves up automatically

hi i am new to iphone. what i need is i want to display an image for example balloon. when ever i click the button the balloon automatically start moveing up vertically from bottom of the simulator to top of the simulator.While it reaches top of the simulator automatically it moves towards down.How can i done this.please post any relevant code or link.Thank you in Advance.
Have a look at this example from Apple you just need to recognize the first touch on the balloon and then make it move wherever you want (by using an animation or manually redrawing the UIImageView representing the balloon each time using a NSTimer)

Moving a UIView along a CGPath according to touch position

I have a line graph I've drawn in Quartz, and a UIView 'bubble' that I'd like to ideally pop up when the user touches the single plot line, and moves their finger along it. The bubble displays some extra graph information.
I'd like to 'attach' the UIView to the CGPath plot, but I'm having trouble conceptually figuring out the best way to do this. I know you can animate a view along a CGPath, but this doesn't seem to work for me, because the user needs to 'scrub' along the graph themselves with their finger rather than any automatic animation.
Does anyone have any suggestions of a good approach?
Maybe you don't need to animate it. Touch events fly by pretty quickly -- maybe if you just move the view to the appropriate location relative to the touch without animation the move will be smooth enough. If that's not good enough, you'll have to animate along the graph segment from the current location of the view (see CALayer presentationLayer) to the desired location. The key is that you'll be animating every time you receive a touch event (and any previous animations would be cancelled).
Like Neil said, your best bet is to just move with the touch events, it will look smooth if all you're doing is moving a view. Use [aTouch locationInView:view] to get the touch's position, then find the closest point on the path (maybe use the x value and look up the y value on the path for the x).

Image in UIScrollView moves offscreen before while zooming

I am working on a photo gallery iPhone app.
Approach is fairly inspired from the ScrollingMadness code available on github.
I have a scroll view which holds all my image views when in paging mode. When user zooms an image using pinch out gesture, I remove all the image views but the current one - and set the content offset to 0,0 (obviously).
Everything works perfect on simulator but on device I face this crazy issue.
When a user pinch out to zoom an image, it goes off screen and when the pinch out touch event ends, it comes back to the screen.
After zooming the image once, if I zoom it further - it does not give me the buggy experience. This leads me to a conclusion that patch needs to be applied where I am removing the other image views from the scroll view and holding the one which is being zoomed.
Not able to figure out how I should make it to work like the iPhone's Photo app. The - magical - Photos app!
Anyone who can point to a direction to get this thing up and running - would be all the help I need right now!
Well, since when you zoom you are moving your picture to (0,0) effectivly the first page, you would expect when the user pinches any page thats not the first one, the image will have to move to 0,0 and therefore you are expiriencing your image moving. After you zoomed once, the image is already at 0,0 so subsequent zooms work fine. Are you finding that zooming on the very first page gives you the behavior you want and only other pages have this issue? If so a fix might be not to move the zooming picture to (0,0) but just keep it where it is and have some dummy view for all your other pages so you dont take up memory from the other pictures. Hope this helps