bla*_*305 0 xcode objective-c interface-builder ios
在xcode中,这是我创建的视图之一:

如果我在模拟器中运行程序,我可以看到这个视图很好.但是,如果我创建一个UIViewController类并将其与此视图挂钩(我确认此视图是一个UIViewController),这就是我在模拟器中得到的:

为什么我会看到这个空白屏幕?如何才能获得看起来像第一张图像的屏幕?
编辑:代码
#import "EnterLevelViewController.h"
@interface EnterLevelViewController ()
@end
@implementation EnterLevelViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)loadView
{
// Implement loadView to create a view hierarchy programmatically, without using a nib.
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
@end
Run Code Online (Sandbox Code Playgroud)
从代码中可以看出,您-(void)loadView已从视图控制器中取消注释该方法,该方法在模板中提供.执行此操作时,控制器将尝试以编程方式构建视图,而不是使用nib(storyboard).完全删除空方法,看看是否有帮助.
| 归档时间: |
|
| 查看次数: |
1021 次 |
| 最近记录: |