AppDelegate.m

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[UIWindow alloc]initWithFrame:[[UIScreen mainScreen] bounds]]; CGRect firstFrame = CGRectMake(16, 240, 100, 150); HypnoView *firstView = [[HypnoView alloc] init]; [self.window addSubview:firstView]; // вот тут вылазит ошибка, если я не подключаю firstView то получаю // *** Terminating app due to uncaught exception // 'NSInternalInconsistencyException', reason: 'Application windows // are expected to have a root view controller at the end // of application launch' self.window.rootViewController = firstView; // а если пишу эту строку то у меня черный экран и // reason: '-[HypnoView _preferredInterfaceOrientationGivenCurrentOrientation:]: // unrecognized selector sent to instance 0x797131e0' firstView.backgroundColor = [UIColor redColor]; self.window.backgroundColor = [UIColor whiteColor]; [self.window makeKeyAndVisible]; return YES; } 

Where is the mistake? And what should be corrected?

    1 answer 1

    Example:

     #import "AppDelegate.h" #import "TableViewController.h" @interface AppDelegate () @end @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { application.statusBarHidden = YES; self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; self.window.rootViewController = [[TableViewController alloc] initWithStyle:UITableViewStylePlain]; [self.window makeKeyAndVisible]; return YES; } @end