UIView animations problem

Hi,
I need some help with a small application I created to learn how animations work. My application consists of one UIView, one UIImageView, 2 buttons for scaling UIImageView up and down.
@class AnimationsViewController;
@interface AnimationsAppDelegate : NSObject <UIApplicationDelegate> {
IBOutlet UIWindow *window;
UIView* theView;
UIImageView* theImageView;
UIButton* scaleUpButton;
UIButton* scaleDownButton;
BOOL scalingUp;
BOOL scalingDown;
@property (nonatomic, retain) UIWindow *window;
- (void)scaleUpButtonTouchDown;
- (void)scaleUpButtonTouchUp;
- (void)scaleDownButtonTouchDown;
- (void)scaleDownButtonTouchUp;
- (void)continueScalingUp;
- (void)continueScalingDown;
@end
- (void)scaleUpButtonTouchDown {
NSLog(@"scale up button touch down");
NSLog(@"ustawiam scalingUp na 1");
scalingUp = YES;
[NSThread detachNewThreadSelector:@selector(continueScalingUp) toTarget:self withObject:nil];
- (void)continueScalingUp {
NSAutoreleasePool * thePool = [[NSAutoreleasePool alloc] init];
NSLog(@"continue scaling up");
while(scalingUp) {
[UIView beginAnimations:nil context:nil];
if(scale<5.03) {
scale+=.01;
NSLog(@"scale up multiplier = %f",scale);
[UIView setAnimationDuration:.15];
CGAffineTransform transform = CGAffineTransformMakeScale(scale,scale);
theImageView.transform = transform;
[UIView commitAnimations];
[thePool release];
- (void)scaleUpButtonTouchUp {
NSLog(@"scale up button touch up inside");
NSLog(@"ustawiam scalingUp na 0");
scalingUp = NO;
- (void)scaleDownButtonTouchDown {
NSLog(@"scale down button touch down");
scalingDown = YES;
[NSThread detachNewThreadSelector:@selector(continueScalingDown) toTarget:self withObject:nil];
- (void)continueScalingDown {
NSAutoreleasePool * thePool = [[NSAutoreleasePool alloc] init];
NSLog(@"continue scaling down");
while(scalingDown) {
[UIView beginAnimations:nil context:nil];
if(scale>.02) {
scale-=.01;
NSLog(@"scale down multiplier = %f",scale);
[UIView setAnimationDuration:.15];
CGAffineTransform transform = CGAffineTransformMakeScale(scale,scale);
theImageView.transform = transform;
[UIView commitAnimations];
[thePool release];
- (void)scaleDownButtonTouchUp {
NSLog(@"scale down button touch up inside");
scalingDown = NO;
So the main view looks like this:
So when I touch the scale up button and hold it, the image should be scaled. And it is, but I cannot see any transition When I touch and hold the button it looks like nothing is happening, but when I release the button, the image is instantly scaled up. It would be really cool if I could see the image getting bigger and bigger while holding the button, so can anyone tell me what am I missing or what am I doing wrong?

I have already tried both:
1. [view setNeedsDisplay]; -> no effect
2. setAnimationBeginsFromCurrentState to YES -> no effect
Thanks for being interested though. I will try to play a bit with delegate methods, just as Pumbaa suggests. But I need some more free time to do this, will post when done.
Message was edited by: lawicko

Similar Messages

  • UIView Animation Problem with different Controllers

    Hello!
    I have a problem regarding the UIView animation and therefore, I have three questions:
    1. is it possible to flip from view old to view new whereby each of the views have their own controller?
    2. Can I only flip views sharing the same controller?
    3. Maybe someone could help me with the following issue: I have two views, and each of the views have their own controller.. the code snippet illustrates my approach.. When i start my code, the new view is added on top of the old view, and the flipping animation is animating the old view only behind the new view.. Sure, this is not what i want to have.
    MapPrototypeAppDelegate *app = (MapPrototypeAppDelegate *)[[UIApplication sharedApplication] delegate];
    ReadGroupsViewController *aReadGroupsViewController = app.readGroupsTableViewController;
    UIWindow *window = app.window;
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationTransition: UIViewAnimationTransitionFlipFromRight forView:[self.mapView superview] cache:YES];
    [UIView setAnimationDuration:1.3];
    [UIView setAnimationDelegate:self];
    [window addSubview:[aReadGroupsViewController view]];
    [UIView commitAnimations];
    thanks..

    sommeralex wrote:
    1. is it possible to flip from view old to view new whereby each of the views have their own controller?
    Yes.
    2. Can I only flip views sharing the same controller?
    The flip animation may be used to transition between any "old" and "new" view without regard to whether those views have different controller's, the same controller, or no controller at all.
    3. Maybe someone could help me with the following issue: I have two views, and each of the views have their own controller.. the code snippet illustrates my approach.. When i start my code, the new view is added on top of the old view, and the flipping animation is animating the old view only behind the new view.. Sure, this is not what i want to have.
    MapPrototypeAppDelegate *app = (MapPrototypeAppDelegate *)[[UIApplication sharedApplication] delegate];
    ReadGroupsViewController *aReadGroupsViewController = app.readGroupsTableViewController;
    UIWindow *window = app.window;
    [UIView beginAnimations:nil context:nil];
    // the next line is puzzling. what is 'self.mapView', and what do you expect its superview to be? If 'self' is a
    // view controller, what is the relationship between its 'view' property and its 'mapView' property? Does 'view'
    // also have a superview? Is 'view' above or below 'mapView'? Is there a view between 'mapView' and the window?
    [UIView setAnimationTransition: UIViewAnimationTransitionFlipFromRight forView:[self.mapView superview] cache:YES];
    [UIView setAnimationDuration:1.3];
    [UIView setAnimationDelegate:self];
    // apropos the question above, what view is being covered in the next statement?
    [window addSubview:[aReadGroupsViewController view]];
    [UIView commitAnimations];
    I think I need a better understanding of the view hierarchy we have before aReadGroupsVC.view is added. The problem you're having is probably caused by passing the wrong view as arg here: [self.mapView superview]. But I can't say for sure since I don't know how mapView is related to the view hierarchy, and I don't know what it's superview is. It might be easier to just explain your "old" view structure and tell us how you want it to change after the flip transition.
    - Ray

  • Multiple UIVIew animations... delays

    I'm finding that when I'm running a UIView animation... an imageview which I'm moving from left to right...
    and I start a second UIView animation of the same type... there's a slight delay in the previous animation... so instead of a smooth motion there's a bit of a jerk.
    also, when one UIView animation ends, I find that there's the same type of delay in the remaining UIVIew animations...
    is there any way to stop such delays...

    And this problem only occurs on the iphone itself... not the simulator.. so maybe it is a question of memory?

  • UIView Animation Question

    To all,
    I have a question about how to handle the asynchronous call when a UIView animation is created. My setup is as follows. I have a method in a view controller that get user input from and then makes external http calls. Since the calls could take a few seconds I wanted to notify the user when the call started and ended. In order to show this message I created a simple animation block in a method which I will list below.
    The animation simply slides a box up with a label on it and then slides it back down. A pop up slider if you will.
    This is my method which does the http processing simplified down.
    My problem is that since the animation call is asynchronous the and takes 4 seconds total to complete. If the HTTP processing takes less then 4 seconds (at times it does) the next displayMessage is called and my animation gets screwed up.
    The thoughts I have had were to have a check to see if the animation was running which is set true in the pop up reveal and false in the popup hide. Then I could simply sleep my thread if the boolean was true. But this wasn't working since the animation stop block was never called.
    I need to bounce ideas of you guys cause I don't know how to get past this basic problem.
    - (void)loadPostViewController:(id)sender
    [self displayMessage:@"Parsing address"];
    //Actual http processing code here which invokes external service
    [self displayMessage:@"Address processed"];
    - (void)displayMessage:(NSString *) inMessage
    CGFloat PostListViewXOFFSET = 20.0f;
    CGFloat PostListViewYOFFSET = 20.0f;
    NSInteger messageWidth = 150;
    NSInteger messageHeight = 60;
    self.transitioning = TRUE;
    self.view.userInteractionEnabled = NO;
    UIView *localContainerView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
    CGRect messageFrame = CGRectMake(0,0,messageWidth, messageHeight);
    roundedRectangle *view = [[roundedRectangle alloc] initWithFrame:messageFrame x:0 y:0 Width:messageWidth Height:messageHeight cIndex:0 radius:10.0f positionIndex:0];
    CGRect frameOut = CGRectMake((localContainerView.bounds.size.width/2)-(messageWidth/2),localConta inerView.bounds.size.height+messageHe ight, messageWidth, messageHeight);
    UILabel *mylabel = [[UILabel alloc] initWithFrame:CGRectMake(PostListViewXOFFSET, PostListViewYOFFSET, messageWidth-40,20)];
    mylabel.font = [UIFont fontWithName:@"Helvetica" size:12];
    mylabel.textColor = [UIColor blackColor];
    mylabel.text = inMessage;
    mylabel.backgroundColor = [UIColor clearColor];
    self.messageLabel = mylabel;
    [view addSubview:mylabel];
    [mylabel release];
    view.frame = frameOut;
    self.messageView = view;
    [self.view addSubview:view];
    [UIView beginAnimations: nil context: nil]; // Tell UIView we're ready to start animations.
    [UIView setAnimationDelegate: self]; // Set the delegate (Only needed if you need to use the animationDid... selectors)
    [UIView setAnimationDidStopSelector: @selector(animationDidStop:finished:context:)]; // example of a selector called with context when animation finishes.
    [UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];
    [UIView setAnimationDuration: 2.0f]; // Set the duration to 4/10ths of a second.
    CGRect frameIn = view.frame; // Get the current frame.
    frameIn.origin.x = (localContainerView.bounds.size.width/2)-(messageWidth/2); // Move the view completely on screen.
    frameIn.origin.y = localContainerView.bounds.size.height-(messageHeight+20.0f);
    view.frame = frameIn; // set the new frame
    [UIView commitAnimations]; // Animate!
    [view release];
    - (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context
    self.transitioning = FALSE;
    [self HideMessage];
    - (void)HideMessage
    NSInteger messageWidth = 150;
    NSInteger messageHeight = 60;
    UIView *localContainerView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
    CGRect frameOut = CGRectMake((localContainerView.bounds.size.width/2)-(messageWidth/2),localConta inerView.bounds.size.height+messageHe ight, messageWidth, messageHeight);
    [UIView beginAnimations: nil context: nil]; // Tell UIView we're ready to start animations.
    [UIView setAnimationDelegate: self]; // Set the delegate (Only needed if you need to use the animationDid... selectors)
    [UIView setAnimationDidStopSelector: @selector(clearMessageView)]; // example of a selector called with context when animation finishes.
    [UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];
    [UIView setAnimationDuration: 2.0f]; // Set the duration to 4/10ths of a second.
    self.messageView.frame = frameOut; // set the new frame
    [UIView commitAnimations]; // Animate!
    }

    To all,
    I have a question about how to handle the asynchronous call when a UIView animation is created. My setup is as follows. I have a method in a view controller that get user input from and then makes external http calls. Since the calls could take a few seconds I wanted to notify the user when the call started and ended. In order to show this message I created a simple animation block in a method which I will list below.
    The animation simply slides a box up with a label on it and then slides it back down. A pop up slider if you will.
    This is my method which does the http processing simplified down.
    My problem is that since the animation call is asynchronous the and takes 4 seconds total to complete. If the HTTP processing takes less then 4 seconds (at times it does) the next displayMessage is called and my animation gets screwed up.
    The thoughts I have had were to have a check to see if the animation was running which is set true in the pop up reveal and false in the popup hide. Then I could simply sleep my thread if the boolean was true. But this wasn't working since the animation stop block was never called.
    I need to bounce ideas of you guys cause I don't know how to get past this basic problem.
    - (void)loadPostViewController:(id)sender
    [self displayMessage:@"Parsing address"];
    //Actual http processing code here which invokes external service
    [self displayMessage:@"Address processed"];
    - (void)displayMessage:(NSString *) inMessage
    CGFloat PostListViewXOFFSET = 20.0f;
    CGFloat PostListViewYOFFSET = 20.0f;
    NSInteger messageWidth = 150;
    NSInteger messageHeight = 60;
    self.transitioning = TRUE;
    self.view.userInteractionEnabled = NO;
    UIView *localContainerView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
    CGRect messageFrame = CGRectMake(0,0,messageWidth, messageHeight);
    roundedRectangle *view = [[roundedRectangle alloc] initWithFrame:messageFrame x:0 y:0 Width:messageWidth Height:messageHeight cIndex:0 radius:10.0f positionIndex:0];
    CGRect frameOut = CGRectMake((localContainerView.bounds.size.width/2)-(messageWidth/2),localConta inerView.bounds.size.height+messageHe ight, messageWidth, messageHeight);
    UILabel *mylabel = [[UILabel alloc] initWithFrame:CGRectMake(PostListViewXOFFSET, PostListViewYOFFSET, messageWidth-40,20)];
    mylabel.font = [UIFont fontWithName:@"Helvetica" size:12];
    mylabel.textColor = [UIColor blackColor];
    mylabel.text = inMessage;
    mylabel.backgroundColor = [UIColor clearColor];
    self.messageLabel = mylabel;
    [view addSubview:mylabel];
    [mylabel release];
    view.frame = frameOut;
    self.messageView = view;
    [self.view addSubview:view];
    [UIView beginAnimations: nil context: nil]; // Tell UIView we're ready to start animations.
    [UIView setAnimationDelegate: self]; // Set the delegate (Only needed if you need to use the animationDid... selectors)
    [UIView setAnimationDidStopSelector: @selector(animationDidStop:finished:context:)]; // example of a selector called with context when animation finishes.
    [UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];
    [UIView setAnimationDuration: 2.0f]; // Set the duration to 4/10ths of a second.
    CGRect frameIn = view.frame; // Get the current frame.
    frameIn.origin.x = (localContainerView.bounds.size.width/2)-(messageWidth/2); // Move the view completely on screen.
    frameIn.origin.y = localContainerView.bounds.size.height-(messageHeight+20.0f);
    view.frame = frameIn; // set the new frame
    [UIView commitAnimations]; // Animate!
    [view release];
    - (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context
    self.transitioning = FALSE;
    [self HideMessage];
    - (void)HideMessage
    NSInteger messageWidth = 150;
    NSInteger messageHeight = 60;
    UIView *localContainerView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
    CGRect frameOut = CGRectMake((localContainerView.bounds.size.width/2)-(messageWidth/2),localConta inerView.bounds.size.height+messageHe ight, messageWidth, messageHeight);
    [UIView beginAnimations: nil context: nil]; // Tell UIView we're ready to start animations.
    [UIView setAnimationDelegate: self]; // Set the delegate (Only needed if you need to use the animationDid... selectors)
    [UIView setAnimationDidStopSelector: @selector(clearMessageView)]; // example of a selector called with context when animation finishes.
    [UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];
    [UIView setAnimationDuration: 2.0f]; // Set the duration to 4/10ths of a second.
    self.messageView.frame = frameOut; // set the new frame
    [UIView commitAnimations]; // Animate!
    }

  • How to cancel an UIView animation?

    If I have started an UIView animation using the UIView animation methods, how to cancel the animation while it is being executed?

    This issue seems to be somewhat complicated.
    There doesn't seem to be any direct way of telling a view to stop animating immediately (either by leaving the view to its current state or moving it immediately to its final state). It also tends to sometimes behave erratically when you try to interrupt an ongoing animation by starting a new one on the same view.
    What would be great is if there was some way of telling a view to stop animating immediately and to remove itself from the animation engine (or whatever it is), similarly to how you can eg. tell an NSTimer to invalidate itself immediately. This would make it easy to then eg. restart the animation or do something else with the view without having to worry about the view still changing after you tried to do something else with it, or about extraneous animationDidStop selector calls (which could mess up things). However, as far as I can see, there's no such feature in UIView.
    What you can try is to start a very short animation and set the animationDidStop selector to call whatever you wanted to do with the view at that point (eg. restart the animation). However, there doesn't seem to be any completely foolproof way of making this work for sure.
    Firstly, you have to make sure that the view actually changes from its current state, else UIView will just skip animating it and never call your new animationDidStop selector, which is a huge nuisance. This also seems to be somehow buggy; in some situations only changing eg. the location of the view or only changing its alpha doesn't properly trigger the animation, while sometimes it does.
    Secondly, it seems to be somewhat erratic whether UIView will call the original animationDidStop selector besides the newly defined one or not. What is worse the original selector might be called after the new one, as if the original animation never actually stopped. Thus you end up with one single animated view calling two different selectors at different points in time, which can mess things up pretty efficiently. And annoyingly, this only happens sometimes, not always.

  • Polygon drawn with CG gets distorted after a UIView animation.

    Hi all,
    I've managed to draw a polygon on an UIView with a helper function that gives me an array of CGPoints which I loop through going CGContextAddLineToPoint.
    I can rotate the polygon by applying a CAAffineTransformMakeRotation object, I have a UIButton associated with a rotate function and it works fine.
    Problem is if I move the UIView down (as with a UIView beginAnimations) and the polygon is rotated in any manner, I can see an animation of it being distorted and disappearing!
    Any clues???

    G'day mate! My favorite San Fran radio station is currently running a 60 sec. travel commercial featuring an authentic Aus announcer (or crocodile hunter) along with an American translator. The idea is to teach us to speak Australian before we get there. I'm a slow learner, but maybe by the time I learn Obj-C I'll know how to ask for directions to Queensland.
    No, I've never been a student at Stanford. CS 193P, last autumn, was given through the Stanford Center for Professional Development, so you didn't need to be a regular Stanford student; an application to the graduate school was required, but all the lectures were on video and I don't think you ever needed to be on campus to complete the course. I think the full tuition was over $3000. I would have gone for that if it had been a live class with the opportunity to ask questions. But I was told questions could only be asked by e-mail and those might or might not be answered in the recorded lectures. I didn't even ask my employer to pay for the class since my job was to develop Win32 apps. At the time I wasn't willing to confide a secret desire to become an iPhone programmer.
    Anyway.. (I can't wait to see the comments about people who litter this forum with their life story) I haven't yet built a test bed to try out your code, but you are indeed moving your subview by resetting the frame. Note the warning in the doc: "If the transform property is not the identity transform, the value of this property is undefined" [https://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIVie wClass/UIView/UIView.html#//appleref/doc/uid/TP40006816-CH3-SW5].
    Try adding a translation to the current transform like this:
    CGAffineTransform t1 = myPolyView.transform;
    CGAffineTransform t2 = CGAffineTransformMakeTranslation(x, y);
    myPolyView.transform = CGAffineTransformConcat(t1, t2);

  • Flash as2 game animation, problem.

    hello i am making a flash animation game but i have a problem, i have my guy running and everything its all gifs, so when he stops its a gif its not one picture its 4 of em (gif) which i made them all compressed into a gif and added to my library then added that to my flash made it work blah blah blah-
    well my problem is when my guy runs left he turn right after i let go of the key i no whats it is doing it using my 1 animation i have in their for standing  i to add my other animation which he standing left basically he runs left after i press left then i let go he turns right, i need to know how to make it so either when i let go of the (LEFT) key it uses my animation ('still2') which is him facing left which i need i have him running right and he stays right after so thats good, or if u know if theres a way i can make the code say like after i let go of like left it uses gotoAndStop('still2') then for running right it uses gotoAndStop('still') so he dosent turn around after i let go of left! well i hope u can find out, and its all animated, so dont just make it so it dosent stop using the animation of left or right, cause then hes running in place for enternity thanks heres my code.
          var rollSpeed = Number=14;
         ichigo_mc.onEnterFrame = function() {
          if (Key.isDown(Key.RIGHT)) {
           this._x += rollSpeed;
           this.gotoAndStop("right");
          } else if (Key.isDown(Key.LEFT)) {
           this._x -= rollSpeed;
           this.gotoAndStop("left");
          } else {
           this.gotoAndStop("still");

    no its actually not a school project just i want to know how to make a game, and i dont know really anything about flash, but i have in my picture of my guy another layer so theres each indivudual layer like i have in my pic of my guy the still still2 running animation 1 n 2 and both my attack things, if you would to see my project so far ask me and i send the file and it should show my guy and his animations...
    heres my code so far.. idk y but i like putting at the end
       var rollSpeed = Number=14;
         var facingRight = true;
         ichigo_mc.onEnterFrame = function() {
          if (Key.isDown(Key.RIGHT)) {
           this._x += rollSpeed;
           this.gotoAndStop("right");
           facingRight = true;
          } else if (Key.isDown(Key.LEFT)) {
           this._x -= rollSpeed;
           this.gotoAndStop("left");
           facingRight = false;
       } else if (Key.isDown(Key.SPACE)) {
        this.gotoAndStop("atack2");
          } else {
           if (facingRight) {
             this.gotoAndStop("still");
           } else {
             this.gotoAndStop("still2");

  • Photoshop Elements 4 Animation Problem

    Hey everyone.
    Sorry for posting this in the iMac forum, but there really was no other forum for my problem. I am using Photoshop Elements 4, and whenever I try to save an animated gif, I cannot edit the frame delay or loop options, they will not respond to anything, but EVERYTHING else will. I have tried uninstalling and reinstalling it, and repairing permissions, and everthing else I can think of. Please help!
    Thanks
    Max

    Hmm... Well, this *****. It's wierd, I got it to animate succcessfully once, but only once, then I couldn't again. Just one more reason to wait for and buy 5 Universal when it comes out I suppose. Thanks for your help.
    Max
    EDIT: Hmm.. I didn't realize this forum had such a strict profanity filter. That wasn't a bad word...

  • Adobe Premiere Elements 8 Gif Animated Problem

    Hey guys , Im currently having problems with my Adobe premiere
    Im trying to import an image thats a .gif but it wont let me sais File not supported
    So I tried importing another .gif image and it worked
    Basically , im trying to import a .gif image and it wont let while letting me import other .gif images except for the one I want
    Thank you

    As I said
    I have another .gif animated image that works with Premiere
    So yeah , .Gifs work
    And I can import that , but I cant import the one I want
    And the problem is my Animated project has 93 frames

  • How do i reduce the number of frames in a UIView animation

    When animating a Uiview... for example the center of a UIImageView.... is there a way to reduce the number of frames that occur during the animation?
    The framerate is too high and making my app slow down significantly... thanks.

    If you do not have an image editor that allows to do that then use one of the online sites to resize images.
    * http://www.shrinkpictures.com/
    * http://www.picresize.com/

  • An animation problem!

    Hi!
    I've been working on a game and I have made an intro for it out of two animated gif files. The problem I am having is running these two files one after another at the start of my program. I can get them to both run at the same time, or one of them to run..but after it runs the second one doesn't come out....like i can't do anythin after i run one of the gif images...any advice would be of great help to me! Thank you!
    Rev

    code?

  • Video Animation problem

    Hello,
    I have come across a problem where if I have applied an effect to a video clip such as Gaussain and make an adjust to the timing of the effect under Video Animation option, it wont save that particular adjustment and wont render it.
    Any help would be appreciated.
    Regards
    David

    It's the slider on picture below... It will work for some of the effects, however sometimes it doesn't - it wont render, meaning the effect will render, but it wont recognise the slider setting eg. the effect will be fully on. The thing is it's not doing it all the time, only sometimes. It might be the specific effect, or perhaps having multiple effectss etc. Not sure, but I have played around with it a lot and can not figure out what is going on.
    David

  • UIButton Animation Problem

    In my application, I have buttons that are moving across the screen, and the objective is to press the buttons as quickly as possible. The animation moves the buttons, but you cannot press the button until the button is in the final position of the animation. Any suggestions/fixes on how to make the button respond to touches while in motion?
    Maybe there is an enable or something I am missing?

    Thanks a lot for your reply.
    Here is more code, it's actually a loop of thread, keep animating this UIButton.
    -(void)startTimer{
    NSAutoreleasePool *pool = [ [ NSAutoreleasePool alloc ] init ];
    stop = NO;
    int i=1;
    while((!stop) && (i<=50)){
    i++;
    totalcount=totalcount+1;
    [self performSelectorOnMainThread:@selector(autoRun) withObject:nil waitUntilDone:YES];
    [NSThread sleepForTimeInterval:1];
    } //while(!stop)
    [ pool release ];
    - (void) autoRun{
    float speed=2.0;
    int startX = round(random() % 310);
    playBtn.frame = CGRectMake(startX, 350.0, 37, 37);
    NSLog(@"speed%f", speed);
    [UIButton beginAnimations:nil context:playBtn];
    [UIButton setAnimationDuration:speed];
    [UIButton setAnimationDelegate:self];
    [UIView setAnimationDidStopSelector:@selector(onAnimationComplete:finished:context:)];
    // set the position where button will move to
    playBtn.frame = CGRectMake(startX, 28.0, 37, 37);
    //[UIButton setAnimationDelegate:self];
    [UIButton commitAnimations];
    //Reset the button state from "Selected" to "Default"
    [playBtn setSelected:NO];
    self.changeScore;
    }

  • Keyboard animation problem.

    Im having various problems after 2.2 update.
    I was posting a message and suddenly the keyboard animation just stopped.
    A minute later i lost internet connection and had to reset the phone.
    Holding the backspace button for 2 seconds results in whole message being deleted letter by letter...
    Is there a fix?
    <Edited by Moderator>

    It was a simple fix, i did not notice the keyboard was in undock mode.

  • Animation problem ( badly needs) ?

    Hello,
    Sorry i 'm posting again and again. because nobody couldn't respond . I badly need this application to be run. Here is what am doing. First applet should start and display '+'( by painting) after keypressed(eg spacebar) then sleep for a while and paint rectangles and next arrow then sleep and etc . this goes on until i keypressed again. Here is that i wrote code , could u please check and modify it. Where i stucked is that KeyPressed code is not working. Please see the code modify it wherever is necessary.
    Thanks in advance,
    - Balaji
    import java.awt.*;
    import java.awt.event.*;
    import java.applet.Applet;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.Color;
    import java.awt.Rectangle;
    import java.awt.GradientPaint;
    import java.awt.geom.GeneralPath;
    import java.awt.Polygon;
    //<applet code="ExptA4.class" width=300 height=300></applet>
    public class ExptA4 extends Applet implements Runnable {
         Thread animator;
         Dimension appSize;
         boolean frozen = false;
         int appWidth = 1000, appHeight = 800;
         int delay = 500;
         java.awt.geom.Ellipse2D.Double circle;
         public void init(){
              appSize = new Dimension(appWidth,appHeight);
              this.setSize(appSize);
             addKeyListener(new KeyAdapter(){
                  public void keyPressed(KeyEvent e){
                  ExptA4 exptA4 = (ExptA4) e.getSource();
                  if (e.getKeyCode() == KeyEvent.VK_SPACE)
                       System.out.println("in the keypressed method ");
                  }// end of if      
                  } // end of keyPressed method
         } // end of init
         public void start(){
              if(frozen)
               { // do nothing
              else
                 if(animator == null) {
                           animator = new Thread(this);
                animator.start();  
               } // end of else
               requestFocus(); 
         } // end of start
         public void stop(){
              // stop the animation thread
              animator = null ;
         } // end of stop
         public void run(){
              Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
              while(Thread.currentThread() == animator)
                      repaint();
                      try {
                     Thread.sleep(5400);
                       } catch (InterruptedException e) {
                             break;
         } // end of run
         public void paint(Graphics g){
              Graphics2D g2 = (Graphics2D)g;
            Rectangle leftRect,rightRect,plus_horz,plus_vert;
            Polygon downArrow = new Polygon();    
           // drawing the plus               
           int xHPoint = 440,yHPoint = 350, widthP = 30, heightP = 30;
           plus_horz = new Rectangle(xHPoint,yHPoint,widthP,heightP-27);
           plus_vert = new Rectangle(xHPoint+10,yHPoint-10,widthP-17,heightP-10);
           // black interior
            g2.setColor(Color.black);
            g2.fill(plus_horz);
            // black border
            g2.setColor(Color.black);
            g2.draw(plus_horz);
           // black interior
            g2.setColor(Color.black);
            g2.fill(plus_vert);
            // black border
            g2.setColor(Color.black);
            g2.draw(plus_vert);
               try{
                     Thread.sleep(4000);
                 } catch (InterruptedException ie)
           // drawing the Rectangle
                  leftRect = new Rectangle(300,300,100,100);
             rightRect = new Rectangle(500,300,100,100);
             // white interior
            g2.setColor(Color.white);
            g2.fill(leftRect);
            // black border
            g2.setColor(Color.black);
            g2.draw(leftRect);
            // white interior
            g2.setColor(Color.white);
            g2.fill(rightRect);
            // black border
            g2.setColor(Color.black);
            g2.draw(rightRect);
           try{
                     Thread.sleep(4000);
                 } catch (InterruptedException ie)
           // drawing downArrow
            int xPointA = 340,yPointA = 340, widthA = 30, heightA = 30;
             downArrow.addPoint(xPointA,yPointA);
            downArrow.addPoint(xPointA+25,yPointA-25);
            downArrow.addPoint(xPointA+13,yPointA-25);
            downArrow.addPoint(xPointA+13,yPointA-75);
            downArrow.addPoint(xPointA-13,yPointA-75);
            downArrow.addPoint(xPointA-13,yPointA-25);
            downArrow.addPoint(xPointA-25,yPointA-25);
            g2.setColor(Color.white);
            g2.fill(downArrow);
            // black border
            g2.setColor(Color.black);
            g2.draw(downArrow);
           try{
                     Thread.sleep(4000);
                 } catch (InterruptedException ie)
       // drawing circle             
           int xPoint = 340,yPoint = 340, width = 30, height = 30;
           circle = new java.awt.geom.Ellipse2D.Double(xPoint,yPoint,width,height);
            // black interior
            g2.setColor(Color.black);
            g2.fill(circle);
            // black border
            g2.setColor(Color.black);
            g2.draw(circle);
           try{
                     Thread.sleep(4000);
                 } catch (InterruptedException ie)
         } // end of paint method
    }

    hi ,
    here is modified code . I kept all sleep methods in the run method.
    But the problem is i couldn't get any response from the keyboard.
    What i need is that whenever key presses then animation should starts.
    please help me in this regard.i 'm putting my code here, please modify
    it according to my requirements. Once again i badly need this one to be run. i really appreciate if anyone help in this one.
    Thanks,
    -balaji
    import java.awt.*;
    import java.awt.event.*;
    import java.applet.Applet;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.Color;
    import java.awt.Rectangle;
    import java.awt.GradientPaint;
    import java.awt.geom.GeneralPath;
    import java.awt.Polygon;
    //<applet code="ExptA5.class" width=300 height=300></applet>
    public class ExptA5 extends Applet implements Runnable,KeyListener {
         Thread animator;
         Dimension appSize;
         boolean frozen = false;
         int appWidth = 1000, appHeight = 800;
         int delay = 500;
      // drawing circle and arrow.
         DrawCircle circle = new DrawCircle();
        DrawArrow downArrow = new DrawArrow();
         public void init(){
            // setting dimension for applet
              appSize = new Dimension(appWidth,appHeight);
              this.setSize(appSize);
              // adding key listener
             addKeyListener(this);
         } // end of init
    // to activate keys
         public void keyPressed(KeyEvent e ){
              System.out.println("in the keypressed method ");
              ExptA5 exptA5 = (ExptA5) e.getSource();
        // when space bar presses then start the thread and animation starts
              if( e.getKeyCode() == KeyEvent.VK_SPACE)
               if ( Thread.currentThread() == animator)
                     exptA5.animator.start();
              } // end of if
         } // end of keyPressed
    // other key methods
         public void keyTyped(KeyEvent e){}
         public void keyReleased(KeyEvent e){}
         // applet starts and animation starts .
         public void start(){
              if(frozen)
               { // do nothing
              else
                 if(animator == null) {
                           animator = new Thread(this);
                animator.start();
               } // end of else
         } // end of start
         public void stop(){
              // stop the animation thread
              animator = null ;
         } // end of stop
         public void run(){
              Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
              while(Thread.currentThread() == animator)
              try {
                 Graphics g = getGraphics();
                   Graphics2D g2 = (Graphics2D)g;          
                  // drawing arrow which is calling from other class
                 downArrow.drawPoly(g2);
                 // sleeps for a while                               
                 Thread.sleep(5400);
                    // drawing circle which is calling from other class
                    circle.drawCircle(g2);
                    // sleeps for a while
                 Thread.sleep(5400);
                 repaint();   
                       } catch (InterruptedException e) {
                             break;
         } // end of run
         public void paint(Graphics g){
         } // end of paint method
    // drawing circle
    public class DrawCircle{
       java.awt.geom.Ellipse2D.Double circle;
       public void drawCircle(Graphics2D g2)
              int xPoint = 340,yPoint = 340, width = 30, height = 30;
          circle = new java.awt.geom.Ellipse2D.Double(xPoint,yPoint,width,height);
          // black interior
          g2.setColor(Color.black);
          g2.fill(circle);
            // black border
          g2.setColor(Color.black);
          g2.draw(circle);
    // drawing Arrow
    public class DrawArrow{
          Polygon downArrow = new Polygon();
       public void drawPoly(Graphics2D g2)
              // drawing downArrow
            int xPointA = 340,yPointA = 340, widthA = 30, heightA = 30;
             downArrow.addPoint(xPointA,yPointA);
            downArrow.addPoint(xPointA+25,yPointA-25);
            downArrow.addPoint(xPointA+13,yPointA-25);
            downArrow.addPoint(xPointA+13,yPointA-75);
            downArrow.addPoint(xPointA-13,yPointA-75);
            downArrow.addPoint(xPointA-13,yPointA-25);
            downArrow.addPoint(xPointA-25,yPointA-25);
            g2.setColor(Color.white);
            g2.fill(downArrow);
            // black border
            g2.setColor(Color.black);
            g2.draw(downArrow);
    }

Maybe you are looking for

  • How to upgrade my mac os x 10.5.8 to 10.6.8

    i have no idea how to update this computer. can someone please help? i got a new i phone 5 but i cnat link it to itunes till have 10.6.8, but i cant do that till i have 10.6 update which i cant fond.

  • Toolbar options are all greyed out and not working

    in trying all the suggestions to fix back button and bookmarks, now my toolbar now longer works at all. it's like the whole system is disintegrating. i have tried all the solutions for back button and toolbar. all those published. no go. now the whol

  • Creating new BAT file script to stop, restart and disable S I agent

    We have just installed BOXI3 and are in the process of updating some bat files for stopping, restarting and failover (to our backup servers)and disable services on the Central Configuration Manager.   In my old scripts we called each service  Example

  • Pass values to stored procedure parameters

    I have a stored procedure in MS SQL 2005 that has a datetime parameter.  I want to be able to use the stored procedure but I only want to pass a date value and assume all times for this date.  When i add the stored procedure to the report it automati

  • Nokia DUAL SIM, WHEN?

    When can we expect the first nokia dual sim mobile phone? Dual sim mobile phone - mobile phone with 2(two) sim cards