2011-08-18 33 views
0

我想使用presentModalViewController將新的視圖添加到我的應用程序。使用presentModalViewController的新視圖的位置問題

ASpotImageViewController *aSpotImage = [[ASpotImageViewController alloc] initWithNibName:@"ASpotImageView" bundle:nil spotID:spotid]; 
aSpotImage.modalTransitionStyle = UIModalTransitionStyleCrossDissolve; 
//NSLog(@"frame is %@", aSpotImage.view.frame); 
//NSLog(@"origin is %@", aSpotImage.view.frame.origin); 
NSLog(@"description is %@", aSpotImage.description); 
[aSpotImage setModalPresentationStyle:UIModalPresentationFullScreen]; 
[self presentModalViewController:aSpotImage animated:YES]; 

但是,當我使用這個,新的視圖出現約40像素左右的屏幕,底部被切斷。什麼可能導致這個?在我使用此代碼的其他情況下,我沒有這個問題。

回答

0

Gurooj,你實現試試這個

UINavigationController *nextController = [[UINavigationController alloc] initWithRootViewController:aSpotImage]; 
[self presentModalViewController: nextController animated: YES]; 

白色空間通常是導航欄的高度,我猜?

+0

這隻會在屏幕上出現一個新的空白導航欄。它實際上留下了一個黑色空間,與我試圖推動的新視圖顏色相同。但父視圖有白色的背景。這隻會讓我更加困惑。 – gurooj

0

您當前的容器的框架爲(320,440,0,40),因此,當您呈現該框架時,它看起來被大量抵消了,儘管實際上它只是將其相對於父容器添加到位置(0,0)。修復方法是根據當前視圖或父視圖重新調整框架。

+0

我該怎麼做?我嘗試過手動調整框架,它似乎沒有改變模態視圖控制器中的任何東西。 – gurooj

+0

即使在橫向模式下,如果我檢查它告訴我的框架{0,0},{768,1024},這是縱向模式的尺寸,我在iPad上面臨同樣的問題。 – ophychius