Question

Alright so i have animations i've pulled from previous apps i have developed that all worked on previous versions of iOS, however the iOS 7 is causing me problems

The weirdest thing is this works perfectly in the ViewController.m (main view) but not in the game.m for now i've been dropping it in the viewDidLoad. In the game view controller it will load the image but it will skip the whole animation so it'll end up at 0,0 as soon as the view loads. in the view controller it'll have the 3 second delay then take 10 sec to animate.

    UIImage *bg1 = [UIImage imageNamed:@"bgImage.png"];
UIImageView *background = [[[UIImageView alloc] initWithFrame:CGRectMake(0, 568, 320, 568)] initWithImage:bg1];
[self.view addSubview:background];

[UIView animateWithDuration:10.0
                      delay:3.0
                    options:UIViewAnimationOptionCurveLinear animations:^{
                        [background setFrame:CGRectMake(0, 0, background.frame.size.width, background.frame.size.height)];
                    }
                 completion:nil
 ];

So my question stands at Why does it work in the ViewController but not GameViewController?I have a feeling it has to do with UIView, so what should be put there?

Was it helpful?

Solution

added to header

UIImageView *background

Revised code

    - (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.


    UIImage *bg1 = [UIImage imageNamed:@"bgImage.png"];
    background = [[[UIImageView alloc] initWithFrame:CGRectMake(0, 568, 320, 568)] initWithImage:bg1];
    [self.view addSubview:background];



}
-(void)viewDidAppear:(BOOL)animated {


    [UIView animateWithDuration:10.0
                          delay:3.0
                        options:UIViewAnimationOptionCurveLinear animations:^{
                            [background setFrame:CGRectMake(0, 0, background.frame.size.width, background.frame.size.height)];
                        }
                     completion:nil
     ];

}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top