2010-12-05 122 views
0

我無法讓我的iPhone應用程序在啓動時顯示任何內容。 任何想法這裏有什麼不對?iPhone - 應用程序總是以空的白色屏幕開始?

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 
    HomeViewController *t = [[HomeViewController alloc] init]; 
    [self.window addSubview:t.view]; 
    [self.window makeKeyAndVisible]; 

    // I tried the following in case the problem is my 
    //view controller but nothing shows up at all 
    UISegmentedControl *t = [[UISegmentedControl alloc] init]; 
    [self.window addSubview:t]; 
    [self.window makeKeyAndVisible]; 
} 

回答

1

除非您的視圖控制器實現loadView,你應該從NIB文件與initWithNibName:bundle:加載視圖。

分段控制應該用initWithItems:進行初始化。您還應該爲控件分配一個框架。

+0

實際上,這是我的問題,我離開了我的筆尖名稱「HomeViewController.m.xib」的名稱中的「.m」,我將其正確地重命名並解決了問題 – aryaxt 2010-12-05 23:16:42

相關問題