在动画帧后,子类UIView无法正确显示

时间:2013-03-07 10:28:56

标签: ios objective-c cocoa-touch uiview animated

我已将[{1}}子类化为基本上包含UIViewUIPickerView

当用户选择选择器中的特定行时,我将在选择器上添加UIToolbar。但是,当我为UIImageView设置动画以向上滑动屏幕时,此图像不可见。如果我没有为UIView设置动画,那么它将正确显示。

我正在显示这样的UIView(在UIImageView中):

UIView

这是我将- (void)showMailSetupPopover { if (self.popoverMailSetupImageView == nil) { UIImageView *popoverMailSetupImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"popover-mail-setup-addreminder"]]; popoverMailSetupImageView.alpha = 0.0; popoverMailSetupImageView.frame = CGRectMake(8, self.frame.origin.y + 65, popoverMailSetupImageView.bounds.size.width, popoverMailSetupImageView.bounds.size.height); self.popoverMailSetupImageView = popoverMailSetupImageView; } [self addSubview:self.popoverMailSetupImageView]; [UIView animateWithDuration:0.5 animations:^{ self.popoverMailSetupImageView.alpha = 1.0; } completion:^(BOOL finished) {}]; } 添加到UIView

的方法
self.view

1 个答案:

答案 0 :(得分:0)

发现问题,

代替

popoverMailSetupImageView.frame = CGRectMake(8, self.frame.origin.y + 65, popoverMailSetupImageView.bounds.size.width, popoverMailSetupImageView.bounds.size.height);

popoverMailSetupImageView.frame = CGRectMake(8, 65, popoverMailSetupImageView.bounds.size.width, popoverMailSetupImageView.bounds.size.height);

self.frame.origin.y不需要。