Black screen on simulation


#1

Im having an issue upon simulating my application. After trying a clean build, Ive found where the error occurs.

I create a new coco-touch objective c class for my view controller, after setting my main interface as QuizViewController.xib, the simulation no longer works (it opens as black) and I am directed to main.m where the line

return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));

is highlighted in green and the notice Thread 1:signal SIGABRT appears

I’ve tried a google search and I can’t find anything on this. I’ve imported the viewcontroller in appdelegate.m and tried following
appcoda.com/hello-world-app- … ode-5-xib/ for using a .xib with this new xocde.

merry christmas, thanks for the help!


#2

That’s because the main-interface-loading machinery was unable to find a view.

To see that this is so, create an XIB file for a window and set your Main Interface to it. The problem goes away!

Here is one way to get around the storyboard: set the Main Interface to blank, and in the AppDelegate.m create a window, load your view controller from its XIB file and set it as the window’s root view controller.

@implementation AppDelegate
...
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    self.window.rootViewController = [[MyRootViewController alloc] init];
    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];
    return YES;
}
...

Here is another way: create an XIB file for a window and add a view controller to it; connect the window’s root view controller outlet to the view controller. Don’t forget to add a view to the controller. Then create a custom view controller and set it as the custom class of your view controller in the XIB file. Finally, set the Main Interface to the XIB file.


#3

[quote=“ibex10”]
To see that this is so, create an XIB file for a window and set your Main Interface to it. The problem goes away!

Here is one way to get around the storyboard: set the Main Interface to blank, and in the AppDelegate.m create a window, load your view controller from its XIB file and set it as the window’s root view controller.

[code]
@implementation AppDelegate

  • (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    self.window.rootViewController = [[MyRootViewController alloc] init];
    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];
    return YES;
    }

    [/code][/quote]

ive tried this, the error persists. it is strange because the quizviewcontroller is already set as the main interface. any other ideas??

edit: when the main interface is set to blank as you suggest, nothing at all loads, as i would expect?


#4

You can’t set the quizviewcontroller’s xib file as the main interface unless the file contains a window. If it contained a window, then you would have to use the second method.


#5

alright i think i understand. im trying with the way below

[quote=“ibex10”]
Here is another way: create an XIB file for a window and add a view controller to it; connect the window’s root view controller outlet to the view controller. Don’t forget to add a view to the controller. Then create a custom view controller and set it as the custom class of your view controller in the XIB file. Finally, set the Main Interface to the XIB file.[/quote]

however, my xib file does contain both a window and a view. im having trouble following the end of your instructions… what more do i need to do? still having problems with the error. merry christmas and thank you again for the help!


#6

all it took was a clean rebuild…for the fourth time. thanks for your help ibex, damn… this xcode can be frustrating at ttimes