2010-04-02 104 views
0

我在添加自定義UIViewController的視圖後,在窗口底部看到了這個空白。在移動到另一個視圖然後再移回之後,視圖向下移動,差距消失。當我將自定義UIViewController添加到窗口時,如何擺脫間隙?

這裏是在應用程序的委託的代碼:

- (void)applicationDidFinishLaunching:(UIApplication *)application {  

    // Override point for customization after application launch 
    CustomViewController *gvc = [[CustomViewController alloc] init]; 
    self.customViewController = gvc; 
    [gvc release]; 

    [window addSubview:customViewController.view]; 
    [window makeKeyAndVisible]; 
} 

「CustomViewController」被用作一個根視圖控制器簡單地座標顯示哪些其他UIViewControllers。因此我只需要設定其觀點=到需要像這樣第一個視圖控制器的看法:

- (void)loadView { 
    UIView *v = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)]; 
    self.view = v; 
    [v release]; 

    // Add the HomeViewController to the top of the stack 
    MainViewController *mvc = [[MainViewController alloc] initWithNibName:@"MainView" bundle:nil]; 
    mvc.delegate = self; 
    self.mainViewController = mvc; 
    [mvc release]; 

    [self.view addSubview:self.mainViewController.view]; 
} 

我已經嘗試了一堆東西,包括你在這裏看到,沒有運氣。有任何想法嗎?

感謝

回答

0

此行

UIView *v = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)]; 

應該是...

UIView *v = [[UIView alloc] initWithFrame:CGRectMake(0, 20, 320, 460)]; 

好時光。

相關問題