我想创建一个只有一个视图的应用程序(TestViewController.h TestViewController.m)。 (没有Tabbar,没有导航栏)不知道为什么我启动应用程序后,屏幕全黑。这似乎应用程序没有成功加载视图?因为如果视图被加载,屏幕应该是白色的。我是对还是不对?当应用程序启动时加载视图
这里的AppDelegate.h
#import <UIKit/UIKit.h>
@class TestViewController;
@interface AppDelegate : UIResponder <UIApplicationDelegate>
{
UIWindow *window;
TestViewController *testrViewController;
}
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) TestViewController *testViewController;
@end
这里的AppDelegate.m
#import "AppDelegate.h"
#import "TestViewController.h"
@implementation AppDelegate
@synthesize window = window;
@synthesize testViewController;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[self.window addSubview:testViewController.view];
[self.window makeKeyAndVisible];
return YES;
}
检查Mainwi ndow.xib,你有'TestViewController'吗? – Hisenberg
@iShrey,我想没有xib文件.. – beryllium
我想创建它没有IB的编程,所以我没有创建xib文件。 – lavitanien