2017-09-14 113 views
-2

我想取消隐藏带有动画的UIView,但它不适用于iphone模拟器5.在取消隐藏除5和5之外的所有其他模拟器后,视图显示正常。如何用动画取消隐藏UIView

可能是什么原因。无法检测到问题。任何帮助?

/*To unhide*/ 
    self.view4.hidden=NO; 

    [UIView animateWithDuration:0.5 animations:^{ 
     self.view4.frame = CGRectMake(2, 70, 70, 300); 
     self.view4.alpha = 1.0f; 
    } completion:^(BOOL finished) { 
    }]; 

    //for showing view3 
    self.view3.hidden=NO; 

    [UIView animateWithDuration:0.5 animations:^{ 
     [self.view3 setFrame:CGRectMake(0, 303, 320, 95)]; 
     self.view3.alpha = 1.0f; 
    } completion:^(BOOL finished) { 
    }]; 
按钮

点击VIEW3不会出现:(。view4显示正常。我还通过改变帧值,但没有取得任何进展试过。在隐藏和减少阿尔法消失的VIEW3动画出现在屏幕上,但不显示它。

iPhone6splus

iPhone5 Screen

回答

0

的问题是很难的一组坐标所使用。如果你检查self.view.bounds(或self.view3.superview。你会注意到视图在iPhone 5上没有相同的尺寸,在iPhone 6/7或iPhone 6Plus/7Plus上没有。您应该计算相对于self.view.bounds指标的视图位置。

// for showing view 3 
self.view3.hidden=NO; 
[UIView animateWithDuration:0.5 animations:^{ 
    CGRect parentBounds = self.view.bounds; 
    CGRect destinationFrame = CGRectMake(0,parentBounds.size.width,parentBounds.size.height-95,95); 
    [self.view3 setFrame:destinationFrame]; 
    self.view3.alpha = 1.0f; 
} completion:^(BOOL finished) { 
}]; 

视图现在应该总是父视图范围内出现,并在iPhone 5

祝你的项目可见!

+0

它不工作:( –

+0

@ShahiJabeen我可以有更多的背景知道这段代码是在UIViewController实现中运行还是在UIView和“self”的关系中运行?你如何创建view3以及它是如何不同的view4是view3的孩子,反之亦然? – ekscrypto

+0

“它不工作”是你可以在SO上说的最不有用的东西之一。详细描述它实际在做什么,描述你的视图是如何设置的并在屏幕上显示它们的状态,并显示完整的代码,而不是片段,你说:“在隐藏和减少alpha消失view3在屏幕上显示动画,但不显示它”,这真的没有道理 –