[英]Why is this simple animation not working on iOS 7?
在我的項目中,我有一個簡單的動畫,我只是從左到右移動一個視圖。 這在iOS 6中運行良好,但是當我在iOS 7中運行它沒有做任何事情。 有人知道為什么嗎? 如果動畫非常簡單,我該如何修復iOS 7? 我的代碼是:
- (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];
}
}
}
我做了更新,我使用Xcode 5和iOS 7所以任何幫助人,你知道如何解決這個問題嗎?
好的,我想我已經解決了。 在iOS 7之前,可以在帶有故事板的viewDidLoad中運行動畫。 如果將動畫調用移動到- (void)viewDidAppear
那么它們應該再次開始工作。 所以在你的情況下你會想要調用[self showAnimation];
in - (void)viewDidAppear
。
- (void)viewDidAppear{
[self showAnimation];
}
我發現在這個方法中放置代碼是有效的。
-(void)viewDidAppear:(BOOL)animated {
menuView.alpha = 0;
topLabel.alpha = 0;
[UIView animateWithDuration:1.5 animations:^{
menuView.alpha = 1;
topLabel.alpha = 1;
}];
[super viewDidAppear:animated];
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.