iPad-iOS 5.1-Xcode 4.3.2
キーボードがポップアップするとき、UIImageViewのy原点を「x」だけ上にアニメーション化します。キーボードが下がるとき、同じ「x」だけ下にアニメーション化します。
つまり、キーボードがポップアップし、画像がXだけ上がり、キーボードが下がり、画像がxだけ下がりますが、同じ場所に表示されるわけではありません。あなたは60上昇し、60下降します、そしてあなたは同じ場所にいません!キーボードの外観と非表示の間で座標系が変化したかのように、さらに下にあります。それは絶対に私を夢中にさせます。なぜこれが起こるのか理解できません。
//add gesture recognizer when keyboard appears
-(void)keyboardWillShow:(NSNotification *) note {
[self.view addGestureRecognizer:tapRecognizer];
// Setup the animation
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.3f];
[UIView setAnimationCurve:UIViewAnimationOptionCurveEaseInOut];
[UIView setAnimationBeginsFromCurrentState:YES];
// The transform matrix: Logo Image
CGAffineTransform moveLogo = CGAffineTransformMakeTranslation(0, -60);
self.logoImageView.transform = moveLogo;
// Commit the changes
[UIView commitAnimations];
}
//add gesture recognizer when keyboard appears
-(void)keyboardWillHide:(NSNotification *) note {
[self.view removeGestureRecognizer:tapRecognizer];
// Setup the animation
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.3f];
[UIView setAnimationCurve:UIViewAnimationOptionCurveEaseInOut];
[UIView setAnimationBeginsFromCurrentState:YES];
// The transform matrix: Logo Image
CGAffineTransform moveLogo = CGAffineTransformMakeTranslation(0, 60);
self.logoImageView.transform = moveLogo;
// Commit the changes
[UIView commitAnimations];
}