简体   繁体   中英

Why is this simple animation not working on iOS 7?

In my project I have a simple animation, I just move a view from left to right. This works fine in iOS 6, but when I run in iOS 7 it does not do anything. Does someone know why? If the animation is very simple how can I fix this for iOS 7? My code is:

- (void) showAnimation
 {
    if (IS_IPAD())
    {
       [UIView animateWithDuration:50.0f 
                             delay:1
                           options:UIViewAnimationOptionRepeat
                        animations:^{
                                         ViewBOLIVIA.frame = CGRectMake(1024,0,  ViewBOLIVIA.frame.size.width, ViewBOLIVIA.frame.size.height);
                                    } completion:nil];
    }
    else
    {
        if (IS_IPHONE_5)
        {
            [UIView animateWithDuration:50.0f 
                                  delay:1 
                                options:UIViewAnimationOptionRepeat 
                              animations:^{
                                               ViewBOLIVIA.frame = CGRectMake(568,0,  ViewBOLIVIA.frame.size.width, ViewBOLIVIA.frame.size.height);
                                          } completion:nil];
        }
        else
        {
             [UIView animateWithDuration:50.0f 
                                   delay:1 
                                 options:UIViewAnimationOptionRepeat
                              animations:^{
                                               ViewBOLIVIA.frame = CGRectMake(480,0,  ViewBOLIVIA.frame.size.width, ViewBOLIVIA.frame.size.height);
                                          } completion:nil];
        }
    }
 }

I did update and Im using Xcode 5 and iOS 7 so any help guys, do you know how fix this?

OK I think I resolved it. Before iOS 7 it was okay to have animations running in viewDidLoad with storyboards. If you move your animation calls to - (void)viewDidAppear then they should start working again. So in your case you will want to call [self showAnimation]; in - (void)viewDidAppear .

- (void)viewDidAppear{
   [self showAnimation];
}

I found placing the code in this method works.

-(void)viewDidAppear:(BOOL)animated {
    menuView.alpha = 0;
    topLabel.alpha = 0;
    [UIView animateWithDuration:1.5 animations:^{
       menuView.alpha = 1;
       topLabel.alpha = 1;
    }];
   [super viewDidAppear:animated];
 }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM