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.
@interface RotationAppDelegate : UIResponder
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) HeavyViewController *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];
// Tell it to start monitoring the accelerometer for orientation
// Get the notification center for the app
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
// Add yourself as an observer
// Bronze challenge - Chapter 8
// Set proximity warning to change color of background to dark grey when close to user’s face
self.window.backgroundColor = [UIColor whiteColor];
(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.