Ios 视图不显示?
在我的应用程序中,当我使用UIView动画切换动画视图时,它不会显示任何内容,视图为黑色,但我知道我的方法正在被调用。我已经记录了视图所在的位置,我打印了结果并将其发布在下面 我的代码在下面,但是有人看到任何错误吗Ios 视图不显示?,ios,animation,views,transition,Ios,Animation,Views,Transition,在我的应用程序中,当我使用UIView动画切换动画视图时,它不会显示任何内容,视图为黑色,但我知道我的方法正在被调用。我已经记录了视图所在的位置,我打印了结果并将其发布在下面 我的代码在下面,但是有人看到任何错误吗 -(void)changeView2ToView3 { NSLog(@"Before, frame= %@", NSStringFromCGRect(view3.view.frame)); [view2.view.superview addSubview:view3
-(void)changeView2ToView3 {
NSLog(@"Before, frame= %@", NSStringFromCGRect(view3.view.frame));
[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];
}];
NSLog(@"Before, frame= %@", NSStringFromCGRect(view3.view.frame));
}
kHeight和kWidth是屏幕的高度和宽度,它们从不为0或零
这也是从控制台打印的内容:
2012-02-02 15:58:30.449 App[27578:707] Before, frame= {{0, 0}, {320, 480}}
2012-02-02 15:58:30.452 App[27578:707] Before, frame= {{0, 0}, {320, 480}}
2012-02-02 15:58:36.234 App[27578:707] Before, frame= {{0, 0}, {320, 480}}
2012-02-02 15:58:36.237 App[27578:707] Before, frame= {{0, 0}, {320, 480}}
谢谢 我正在开发的一个应用程序也发生了类似的事情。我认为你的错误在于没有指定高度或宽度,它们都是0?如果我错了,请纠正我。kWidth和kHeight是屏幕的宽度和高度,它们不是0或零,因此这不是问题所在:/