2012-02-04 101 views
0

在我的應用程序中,當我使用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}} 

謝謝!

回答

1

類似的事情發生在我身上,我正在使用一個應用程序。我認爲你的問題是你沒有指定高度或寬度,他們都是0?糾正我,如果我錯了。

+1

kWidth和kHeight是屏幕的寬度和高度,它們不是0或零,所以這不是問題:/ – 2012-02-04 22:39:43