视图不显示?
问题描述:
在我的应用程序中,当我使用UIView动画切换视图时,它不显示任何内容,视图是黑色的,但我知道我的方法正在调用。我已NSLogged视图的位置,我打印结果并张贴在下面。视图不显示?
我的代码在下面,但没有人看到任何错误?
-(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或零,所以这不是问题:/ – 2012-02-04 22:39:43