iPhone - 应用程序始终以空白屏幕开始?

时间:2010-12-05 23:01:18

标签: iphone uiviewcontroller uisegmentedcontrol

我无法让我的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 个答案:

答案 0 :(得分:1)

除非您的视图控制器实现loadView,否则您应该使用initWithNibName:bundle:从NIB文件加载视图。

应使用initWithItems:初始化分段控件。您还应该为控件分配一个框架。