为什么移动UIView不移动UIImageView在同一视图?

我有一个UIView上的ImageView。 我试图移动视图键盘大小,但所有的内容正常,而不是UIImageView移动。

-(void) keyboardWillShow:(NSNotification *) notification { NSDictionary* keyboardInfo = [notification userInfo]; // Work out where the keyboard will be NSValue* keyboardFrameBegin = [keyboardInfo valueForKey:UIKeyboardFrameBeginUserInfoKey]; CGRect keyboardFrameBeginRect = [keyboardFrameBegin CGRectValue]; // Work out animation duration NSTimeInterval animationDuration =[[keyboardInfo valueForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue]; UIViewAnimationOptions keyboardAnimationCurve = [[keyboardInfo valueForKey:UIKeyboardAnimationCurveUserInfoKey] integerValue]; // Animate this [UIView animateWithDuration:animationDuration delay:0.0 options:keyboardAnimationCurve animations:^(){ self.view.frame = CGRectOffset(self.view.frame, 0, -keyboardFrameBeginRect.size.height); } completion:NULL]; [UIImageView animateWithDuration:animationDuration delay:0.0 options:keyboardAnimationCurve animations:^(){ self.imgBankLogo.frame = CGRectOffset(self.imgBankLogo.frame, 0, -keyboardFrameBeginRect.size.height); } completion:NULL]; } 

任何人有同样的问题或build议? 我甚至试图移动UIImage,但它并没有移动。

在这里输入图像说明

正如你可以看到除了imageview以外的所有东西!

在这里输入图像说明

如果您试图将两个视图一起移动,而另一个视图是另一个视图的子视图,则不需要单独为它们设置animation。

animation父视图应自动移动所有的子视图。 试图在同一时间单独制作animation会导致我的经验怪异的结果。 这个animation块应该是你所需要的。 您可能还想检查视图文件检查器选项卡中的自动布局设置。

如果要同时执行多个animation,则可以在同一个animation块中添加多个调用。

 [UIView animateWithDuration:animationDuration delay:0.0 options:keyboardAnimationCurve animations:^(){ //you can add multiple here self.view.frame = CGRectOffset(self.view.frame, 0, -keyboardFrameBeginRect.size.height); } completion:NULL];