切换视图时第二次视图不显示?
在我的应用程序中,当我使用 UIView 动画切换动画视图时,第一次切换视图时效果很好,因为视图正确滑动到位并且一切正常。但是,如果我切换回原始视图,然后返回新视图,它不会显示任何内容,视图是黑色的,但我知道我的方法正在被调用。
我的代码如下,但有人看到有什么问题吗?
-(void)changeView2ToView3 {
[view2.view.superview addSubview:view3.view];
[view3.view setFrame:CGRectMake(0, kHeight, kWidth, kHeight)];
[UIView animateWithDuration:0.75
animations:^{
[view3.view setFrame:CGRectMake(0, 0, kWidth, kHeight)];
}
completion:^(BOOL finished){
[view2.view removeFromSuperview];
}];
}
kHeight 和 kWidth 是屏幕的高度和宽度,它们绝不是 0 或 nil。
谢谢!
In my app when I am switching views with an animation using UIView animations, it works fine the first time when I switch views because the view slides properly into place and everything works. But if I switch back to my original view and then go BACK to the new view, it does not show anything, the view is black but I know my method is getting called.
My code is below, but does anyone see anything that is wrong?
-(void)changeView2ToView3 {
[view2.view.superview addSubview:view3.view];
[view3.view setFrame:CGRectMake(0, kHeight, kWidth, kHeight)];
[UIView animateWithDuration:0.75
animations:^{
[view3.view setFrame:CGRectMake(0, 0, kWidth, kHeight)];
}
completion:^(BOOL finished){
[view2.view removeFromSuperview];
}];
}
kHeight and kWidth are the height and width of the screen and they are never 0 or nil.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
第一次之后,view2.view 的 superview 必须为零。所以你必须设置一个变量来保存超级视图。
After the first time, view2.view's superview must be nil. So you have to set a variable for saving the superview.