Bronze Challenge Black Screen


#1

Hi I was able to implement the Bronze Challenge just fine. I set the proximityChanged method in the HeavyViewController and the addObserver: parameter to hvc. ANYWAYS, everything works fine, I get the gray screen BUT I notice as I am lifting my iPhone 4Gs up a the screen goes black for a second between changing colors (I’m assuming it’s when the Notification is caught). Is this “expected” behavior?
I’m assuming it has something to do with the screen turning off when you are talking on the phone. How to disable this if possible.


#2

[quote=“vergilcastelo”]Hi I was able to implement the Bronze Challenge just fine. I set the proximityChanged method in the HeavyViewController and the addObserver: parameter to hvc. ANYWAYS, everything works fine, I get the gray screen BUT I notice as I am lifting my iPhone 4Gs up a the screen goes black for a second between changing colors (I’m assuming it’s when the Notification is caught). Is this “expected” behavior?
I’m assuming it has something to do with the screen turning off when you are talking on the phone. How to disable this if possible.[/quote]

What are you actually doing when you catch the notification? Notifications may arrive on a non-main thread; then if you do GUI stuff in your notification handler, you are bound to get nasty surprises. You should schedule a method-execution request in the main-event loop with performSelectorOnMainThread:withObject:waitUntilDone:
(See: NSObject Class Reference)


#3

In my RotationAppDelegate.m I set the root view controller to the HeavyViewController, then I add the device as an observer like so:

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

    
    [nc addObserver:hvc
           selector:@selector(proximityChanged:)
               name:UIDeviceProximityStateDidChangeNotification
             object:device];

and in the HeavyViewController.m I add the proximity change:

- (void)proximityChanged:(NSNotification *)note
{
    //Log it
    NSLog(@"proximity changed");
    [[self view] setBackgroundColor:[UIColor darkGrayColor]];
}

#4

For some reason Siri comes in when proximityState changes to 1!!

…any reason for that?