私は新しいウィンドウベースのプロジェクトを作成しましたが、何もしていない理由を理解できませんでした。最終的にdidFinishLaunchingの直後にNSLogを置いて、それを実行するとログに記録されません。didFinishLaunchingは決して呼び出されません
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSLog(@"didFinishLaunching");
// Get the device object and turn proximity monitoring on
UIDevice *d = [UIDevice currentDevice];
[d setProximityMonitoringEnabled:YES];
// Get the NSNotificationCenter object
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
// Sign up to receive notifications when the proximity state changes
[nc addObserver:self selector:@selector(proximityChanged:) name:UIDeviceProximityStateDidChangeNotification object:d];
NSLog(@"Observing...");
[self.window makeKeyAndVisible];
return YES;
}
- (void)proximityChanged:(NSNotification *)note {
// Print out the changes of proximity state
NSLog(@"Proximity Changed: %d", [[note object] proximityState]);
}
私が書いたと私はシミュレータ上または私のデバイス上でそれを実行したときに何も記録されません何の全体です:ここで私が書いたコードのすべてです。何かご意見は?