简体   繁体   中英

Animation working on iPhone but NOT working on iPad

I have an app developed for both iPhone and iPad. All features work on both devices, both on emulator and on a real devices. All but one. I'm using storyboards and I triple checked if I connected everything in both iPad and iPhone Views with the same class I am using.

That one feature that isn't working is animation of an UIImageView .

So, I have this image that I want to move to another location, called on - viewDidAppear .

here is the code:

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:2];
_fessor.frame = (CGRectMake(_sweden.frame.origin.x+20, _sweden.frame.origin.y-10,  
_fessor.frame.size.width, _fessor.frame.size.height));
[UIView commitAnimations];

// _fessor is ImageView im animating;

// _sweden is the button representing the country I want my _fessor to go to

So, this code works perfectly on iPhone (both emulator and a real device). So why shouldn't it work on iPad (again, both emulator and device)

Also, if anyoneneeds some more data, just tell me which exactly data you need. Cos I don't see what else could cause the problem

EDIT: The animation DOES work, when I click on a button and call the animation method. But it DOESN'T work when I call it on - viewDidAppear The animation DOES work, when I click on a button and call the animation method. But it DOESN'T work when I call it on - viewDidAppear

Use this block for animations:

[UIView animateWithDuration:2.0 delay:0. options:UIViewAnimationOptionCurveEaseInOut animations:^{
    _fessor.frame = (CGRectMake(_sweden.frame.origin.x+20, _sweden.frame.origin.y-10,
                                _fessor.frame.size.width, _fessor.frame.size.height));
} completion:^(BOOL finished) {
    // when your animation finished
}];

First check all the value you are passing is related with ipad size

May be issue is: you are passing frame size is perfect for iphone but not perfect for iPad.

May be useful:

CGRect screenBound = [[UIScreen mainScreen] bounds];
CGFloat screenWidth = screenBound.size.width;
CGFloat screenHeight = screenBound.size.height;

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