- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController_iPhone" bundle:nil] autorelease];
} else {
self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController_iPad" bundle:nil] autorelease];
}
CustomView1 *CustomView = [[CustomView1 alloc]initWithFrame:[[UIScreen mainScreen] bounds]];
self.viewController.view = CustomView;
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
This appears in AppDelegate.m
I want to change rootViewcontroller‘s view to CustomView, and tried the code above, but the background color remained black and touch event weren’t accepted.
Where is the error?
I am not sure where the fault is but I have 2 suggestions.
1) Change
to
or
2) In both you .xib files referenced go to the top view and change it to use a custom class. Then you can just let the app launch like normal
Side note:
You should avoid naming variables that begin with uppercase letters. Many coding standards have classes begin with uppercase letters and variables begin with lower case letters.