Xcode 4.2 and this section


#1

Maybe it’s me, but after looking at the Xcode 4.2 suggestion and seeing that I’m out of the xib file programming now, this section shouldn’t have as many problems. However, I keep getting the following error: 2011-11-26 16:55:53.091 Hypnosister[1196:f803] Applications are expected to have a root view controller at the end of application launch, and a break on main.m. In addition, I’ve told Xcode to use iOS 4.3, and target for 4.3 with the 5.0 SDK. Is there something I’m missing?

Thanks!


#2

Ok, I just noticed an error in my code, I needed the following before the code outlined in the book first.

Once I had that, the iOS simulator shows half the screen with the circles, and the other half as black. Am I still missing something?

Edit: found this stackoverflow.com/questions/3276 … -simulator, and while it does help to outline the scaling function and how to use it, I’m only getting a “scaling factor” of 1 on the iOS 4.3 and 5.0 simulator. Is it working differently on devices?

Final Edit: And this is why I shouldn’t code at 11pm at night. I had M_PI in HypnosisView as just M_PI, and not M_PI * 2.0… As a final note, on iOS 5, you have to set background as whiteColor instead of clearColor otherwise you have grey on black.


#3

Hi! I am going through your same problem but I can’t fix it up.

with the following code console show me up “Hypnosister[2361:f803] Applications are expected to have a root view controller at the end of application launch” and the simulator shows a WHITE view area (not gray and so let me think that something goes right and something goes wrong but I can’t figure it out)

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
    CGRect wholeWindow = [[self window] bounds];
    view = [[HypnosisView alloc] initWithFrame:wholeWindow];    
    [view setBackgroundColor:[UIColor whiteColor]];
    [[self window] addSubview:view];
    [self.window makeKeyAndVisible];
    return YES;
}

Where am I wrong?

Thanks!


#4

Solved… I’ve insert my HypnosisView in ViewController and added it into the xib and all worked correctly


#5

That console output is just a suggestion. You can safely ignore it.


#6

I tried implementing the solution by sticking the code in the ViewController class, but the problem there is that it was complaining that it didn’t have access to the window data member. I then tried to stick the code in the AppDelegate class, but then it wouldn’t render at all. I think the problem with the Xcode 4.2 template is that the xib file is loaded at the end of the application:didFinishLaunchingWithOptions method, which essentially wipes out any drawing you just did! So I solved the problem like this …

[code]- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];

// Override point for customization after application launch.
self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController" bundle:nil] autorelease];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];

[self DrawTheView];

return YES;

}

  • (void)DrawTheView
    {
    CGRect wholeWindow = [[self window] bounds];
    view = [[HypnosisView alloc] initWithFrame:wholeWindow];
    [view setBackgroundColor:[UIColor whiteColor]];
    [[self window] addSubview:view];

}
[/code]

It then worked fine. And yes… I changed the colors to my liking.