2010-07-26 53 views
0

我有我的iPhone應用程序中我的UITextFields問題,我希望有人在這裏可能見過。UITextField編輯問題 - iPhone SDK

我在屏幕上有幾個UITextField,當它們被點擊時,它們的鍵盤出現,它們被覆蓋。爲了克服這個問題,我的動畫視圖與動起來:

-(void)moveViewUpFromValue:(float)fromOldValue toNewValue:(float)toNewValue keep:(BOOL)keep { 

    CABasicAnimation *theAnimation; 
    theAnimation=[CABasicAnimation animationWithKeyPath:@"transform.translation.y"]; 
    theAnimation.duration=0.25; 
    theAnimation.repeatCount=1; 
    if(keep) { 
     [theAnimation setRemovedOnCompletion:NO]; 
     [theAnimation setFillMode:kCAFillModeForwards]; 
    } 
    theAnimation.fromValue=[NSNumber numberWithFloat:fromOldValue]; 
    theAnimation.toValue=[NSNumber numberWithFloat:toNewValue]; 
    [self.view.layer addAnimation:theAnimation forKey:@"animateLayer"]; 

} 

此,在視覺上,偉大的作品,但是,當我去編輯(按住屏幕下去把放大鏡),它不出現。互動在移動前保留在該位置。

任何想法可能會發生什麼?

非常感謝, 佈雷特

回答

0

這是動畫這樣的事情一個有趣的方式,但不是最常見的一種。

您實際上正在爲視圖的轉換設置動畫 - 而不是視圖的實際位置。顯然,放大鏡不遵守轉換(非常合乎邏輯,因爲它會變得透明,否則會延伸並歪斜)。

所以寧可動畫位置,即self.view.frameself.view.center(歸結爲相同的東西)。此外,我通常使用[UIView beginAnimations...]等,但如果你的方法有效,它可能是一樣好。

+0

就是這樣。謝謝一堆!看了一會兒之後,我確實認爲[UIView beginAnimations ...]可能是最好的方法。 – Brett 2010-07-26 20:06:00

0

你所做的觀點似乎是在不同的地方,但因爲你還沒有真正改變了立場它有效地仍然是在原來的位置的東西像命中測試等

我會首先動畫您的視圖的中心,而不是其轉換。這隻需要一個UIView動畫而不是CABasicAnimation。此外,當動畫完成時,您的視圖實際上會在正確的位置結束,所以事情應該按照您的預期工作。