Bronze Challenge Problem - Screen just goes black


Okay, here I am again to ask questions about a challenge. It seems like what I have coded would work - yet it doesn’t. My selector gets triggered and my NSLog gets printed out, but when the phone gets close to my face it just goes black. I have tried this every which way. This is the code that works to get the NSLog to print out. But, again, the screen just goes black.

Any help is ENORMOUSLY appreciated.


[code]#import <UIKit/UIKit.h>
#import “HeavyViewController.h”

@interface RotationAppDelegate : UIResponder

@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) HeavyViewController *hvc;



[code]#import “RotationAppDelegate.h”
#import “HeavyViewController.h”

@implementation RotationAppDelegate

@synthesize hvc;

  • (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.

    // Get the device object
    UIDevice *device = [UIDevice currentDevice];

    // Create instance of HeavyViewController and set it as the RootViewController

    hvc = [[HeavyViewController alloc]init];
    [[self window]setRootViewController:hvc];

    // Tell it to start monitoring the accelerometer for orientation
    [device beginGeneratingDeviceOrientationNotifications];

    // Get the notification center for the app
    NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];

    // Add yourself as an observer
    [nc addObserver:self

    // Bronze challenge - Chapter 8
    // Set proximity warning to change color of background to dark grey when close to user’s face
    [device setProximityMonitoringEnabled:YES];
    [nc addObserver:self

    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];
    return YES;

  • (void) orientationChanged: (NSNotification *) note
    // log the constant that represents the current orientation
    NSLog(@“orientationChanged: %d”, [[note object]orientation]);

  • (void) changeBackgroundColor: (NSNotification *) note
    // Bronnze Challenge - Chapter 8
    // Change background to dark grey when device is close to face
    NSLog(@“Background changed because you are now close enough to lick your screen.”);
    self.window.backgroundColor = [UIColor darkGrayColor];


P.S. I’ve tried using hvc as my observer but then my changeBackgroundColor selector doesn’t trigger at all, and I do not get the NSLog print out.


See: … reen-black


Thank you!