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];
}
I can't get my iPhone app to display any of the content on startup.
Any idea what's wrong here?
- (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];
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
除非您的视图控制器实现了
loadView
,否则您应该使用initWithNibName:bundle:
从 NIB 文件加载视图。分段控件应使用
initWithItems:
进行初始化。您还应该为控件分配一个框架。Unless your view controller implements
loadView
, you should load the view from a NIB file withinitWithNibName:bundle:
.A segmented control should be initialized with
initWithItems:
. You should also assign a frame to the control.