Thursday, July 19, 2018

#1 2010-10-04 10:44:29 am

RIRedinPA
Member
From:: Philadelphia
Registered: 2003-11-12
Posts: 237
Website

Obj-c: moving an image view

I'm trying to simply move an image view from right to left starting at position 0, 0 and ending at -280, 0 but I can't seem to get the code working...

in the viewController .h file

IBOutlet UIImageView *testbg;

in the .m

- (void)viewDidLoad {
   
    //move background image
    int i;
    int newX;
    NSLog(@"%d", testbg.center);
   
    for(i=0; i < 280; i++) {
        newX = i*-1;
        [UIView beginAnimations:@"test" context:NULL];  //context is not needed in this example.  Also, it's good to name your animation.
        [UIView setAnimationDelegate:self];
        [UIView setAnimationDuration:0.1];
        [UIView setAnimationDidStopSelector:@selector(theAnimationDidStop:finished:context:)];
        testbg.center = CGPointMake(newX, 0);
        [UIView commitAnimations];
    }
   
    [super viewDidLoad];
}

doesn't break but doesn't work either.

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)