Moving UIButton around

Posted by pbcoder on Stack Overflow See other posts from Stack Overflow or by pbcoder
Published on 2010-05-03T16:36:59Z Indexed on 2010/05/03 16:38 UTC
Read the original article Hit count: 254

Filed under:
|
|

I've tried to move a UIButton up and down in a menu. The problem I've got with the following solution is that the timer is not accurate. Sometimes the Button is moved up 122px, sometimes only 120px. How I can fix this?

    -(IBAction)marketTabClicked:(id)sender {

    if (marketTabExtended) {
        NSLog(@"marketTabExtended = YES");
        return;
    }
    else {
        if (iPhoneAppsExtended) {
            timer = [NSTimer scheduledTimerWithTimeInterval:0.005 target: self selector: @selector(animateItemApps) userInfo: nil repeats: YES];
        }
        else {
            if (homepageExtended) {
                timer = [NSTimer scheduledTimerWithTimeInterval:0.005 target: self selector: @selector(animateItemHomepage) userInfo: nil repeats: YES];
            }
            else {
                timer = [NSTimer scheduledTimerWithTimeInterval:0.005 target: self selector: @selector(animateItemMarketing) userInfo: nil repeats: YES];
            }

        }

    }

    [self performSelector:@selector(stopTimer) withObject:self afterDelay:0.605];
    iPhoneAppsExtended = NO;
    homepageExtended = NO;
    marketTabExtended = NO;
    marketTabExtended = YES;

}



-(void)animateItemApps {
    CGPoint movement;
    movement = CGPointMake(0, -1);
    homepage.center = CGPointMake(homepage.center.x, homepage.center.y + movement.y);
}

-(void)animateItemHomepage {
    CGPoint movement;
    movement = CGPointMake(0, 1);
    homepage.center = CGPointMake(homepage.center.x, homepage.center.y + movement.y);
    //marketTab.center = CGPointMake(marketTab.center.x, marketTab.center.y + movement.y);
}

-(void)animateItemMarketing {
    CGPoint movement;
    movement = CGPointMake(0, -1);
    //marketTab.center = CGPointMake(marketTab.center.x, marketTab.center.y + movement.y);
    homepage.center = CGPointMake(homepage.center.x, homepage.center.y + movement.y);
}

-(void)stopTimer {
    [timer invalidate];
}

© Stack Overflow or respective owner

Related posts about iphone

Related posts about ipad