【发布时间】:2014-03-10 12:10:58
【问题描述】:
我以编程方式创建了视图,但它没有显示在屏幕上 并在控制台中给出一条消息
无法为 UIMainStoryboardFile 'Main' 实例化默认视图控制器 - 可能 指定的入口点没有设置?
这是我的代码
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary
*)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] ;
exmTableViewController *vc =[[exmTableViewController alloc] init];
self.window.rootViewController=vc;
self.window.backgroundColor =[UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}
*Viewdidload 中的代码 *
- (void)viewDidLoad
{
[super viewDidLoad];
UIImageView *img =[[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 100, 20)];
self.imageView=img;
[self.view addSubview:self.imageView];
UILabel *lbl =[[UILabel alloc] initWithFrame:CGRectMake(10, 10, 100, 20)];
lbl.text =@"Hello";
self.view =lbl;
}
【问题讨论】:
-
如果您使用故事板,请不要将任何内容分配给您的根视图控制器。或者,如果您这样做,请摆脱情节提要。
标签: ios storyboard viewcontroller