Advertise here




Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID
Please do not post the same thing multiple times. The board software automatically flags certain posts as needing moderator attention. This happens the most often for new users. I'm pretty sure this is made clear at the time you attempt to post. Posting the same thing over and over again just makes that many more posts the moderators have to weed through later. This makes us sad. Don't make us sad. If your post/thread doesn't appear, just wait a while. Don't post it again. If it hasn't shown up by the next day, then you can try again. I normally go through posts in the mornings, and try to check a few times throughout the day, but I'm not here 24/7. There will typically be a significant delay before posts are approved. Just be patient.

Rotate an image 360 degrees by touching on it...

anr164anr164 Posts: 25Registered Users
Hey guys,
would like to tell you first of all that Im fairly new on Xcode so I really need help and very much so.

This is what I want to achieve:

I have an image that I would like to rotate 360 degrees in 35 seconds whenever the user touches it. Is it possible to get and alert whenever the animation is completed? Is it possible to change image when the animation is completed?

Please guys i really need help on this one...
Please tell me witch framework to import (quartz-core?) and what to put in "Myproject.h" and "Myproject.m"

Thanks for your help!!
Post edited by anr164 on

Replies

  • smithdale87smithdale87 Posts: 4,293iPhone Dev SDK Supporter
    Check out UIView class reference

    Specifically, look at
    UIView animateWithDuration:animations:completion:


    Specifically, your animation will need to alter the transform property of the UIView to give it the rotation. Then, to do stuff once the animation has completed, you would use the completion block parameter.

    Note, there are plenty of code samples in the documentation.
  • anr164anr164 Posts: 25Registered Users
    smithdale87;414968 said:
    Check out UIView class reference

    Specifically, look at
    UIView animateWithDuration:animations:completion:


    Specifically, your animation will need to alter the transform property of the UIView to give it the rotation. Then, to do stuff once the animation has completed, you would use the completion block parameter.

    Note, there are plenty of code samples in the documentation.
    thanks mate, but i think i need more more more help :(
  • smithdale87smithdale87 Posts: 4,293iPhone Dev SDK Supporter
    How much more? You want to have the solution spoon fed to you? Look at the link I posted. It has great example code. I'm not sure what more you could want?
  • Duncan CDuncan C Posts: 8,033Tutorial Authors, Registered Users
    anr164;414966 said:
    Hey guys,
    would like to tell you first of all that Im fairly new on Xcode so I really need help and very much so.

    This is what I want to achieve:

    I have an image that I would like to rotate 360 degrees in 35 seconds whenever the user touches it. Is it possible to get and alert whenever the animation is completed? Is it possible to change image when the animation is completed?

    Please guys i really need help on this one...
    Please tell me witch framework to import (quartz-core?) and what to put in "Myproject.h" and "Myproject.m"

    Thanks for your help!!
    Sure it's possible. You need to use a framework called "Core Animation"

    Doing a 360 degree animation is a little tricky, because the system gets confused. 360 degrees puts you back where you started, and it isn't clear what you wanted. You want to do a series of 3 rotations of 120 degrees apiece, ending up at 360 degrees.

    You do indeed need the QuartzCore framework.

    You will want to look at UIView animations. You want a method like animateWithDuration:animations:completion:

    What you will want to animate is your image view's transform property.

    That method lets you pass in a block of code that gets executed once the animation is complete. You'd trigger 3 animations of 120 degrees each, and then trigger whatever code you want once the image has rotated by the full amount.

    No, We're not going to "tell [you]... what to put in 'Myproject.h' and 'Myproject.m'." That amounts to writing your code for you. I'm available for hire if you'd like to hire my company to develop your app for you, but otherwise, we'll give help and suggestions, not do your work for you.

    There is an excellent Core Animation demo project on the net, written by a guy named Bob McCune. You can download it here:

    Core Animation Presentation
    Regards,

    Duncan C
    WareTo

    mug

    Animated GIF created with Face Dancer, available for free in the app store.
Sign In or Register to comment.