2013-10-22 132 views
0

我有一款爲iPhone和iPad開發的應用程序。 所有功能均可在仿真器上和真實設備上的兩種設備上使用。除一個之外。 我正在使用故事板和三重檢查,如果我連接iPad和iPhone視圖與我使用的同一類的所有內容。動畫在iPhone上工作,但不在iPad上工作

那個不起作用的功能是動畫UIImageView

所以,我有這個圖像,我想移動到另一個位置,呼籲 - viewDidAppear

這裏是代碼:

[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 

因此,此代碼的工作完全在iPhone(包括模擬器和實際設備)。 那麼,爲什麼它不能在iPad上工作(再次,仿真器和設備)

此外,如果任何人需要更多的數據,告訴我你需要哪些數據。因爲我看不出還有什麼可以導致問題

編輯: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

+1

'beginAnimations:'和'commitAnimations:'一直以來的iOS4支持的UIView的基於塊的動畫方法氣餒。你試過這樣做嗎? – Abizern

+0

不是。我沒有...我會試一試 – SteBra

回答

1

使用此塊動畫:

[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 
}]; 
-1

首先檢查所有你逝去的是與iPad尺寸

相關值

可能是問題是:你正在傳遞框架大小是完美的iPhone,但不完美的iPad。

可能有用:

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