- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我创建了一个新的基于窗口的项目,但不知道为什么它什么也没做。最终,我在 didFinishLaunching 之后放置了一个 NSLog,并且在我运行它时它从未记录过。这是我编写的所有代码:
- (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]);
}
最佳答案
好吧,您在谈论应用程序委托(delegate)。显而易见的原因 - 您的对象未设置为应用程序委托(delegate) .
查看Apple文档有很多方法可以完成它:
The application delegate is a custom object that you provide at application launch time, usually by embedding it in your application’s main nib file. The primary job of this object is to initialize the application and present its window onscreen. The UIApplication object also notifies this object when specific application-level events occur, such as when the application needs to be interrupted (because of an incoming message) or moved to the background (because the user tapped the Home button).
The fourth parameter identifies the class of the application delegate. The application delegate is responsible for managing the high-level interactions between the system and your custom code. Specifying nil tells UIKit that the application delegate object is located in the application’s main nib file (which is the case for applications built using the Xcode templates).
关于iphone - 从未调用 didFinishLaunching,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6963130/
背景 我最近在 merge 期间遇到了一个意外未 merge 的文档文件的问题。 无论出于何种原因,我搞砸了 merge 并有效地删除了文件(和其他几个文件),因为我忘记了它们的存在。 现在我想查看我
我在我的网站上使用旧的 mysql 版本和 php 版本 4。 我的表结构: | orders_status_history_id | orders_id | orders_status_id |
我是一名优秀的程序员,十分优秀!