2

我正在尝试检查我的 iOS 应用程序的应用程序状态,但是当我检查

[UIApplication sharedApplication].applicationState

我越来越零了。我检查了 [UIApplication sharedApplication] 不为零。我基本上只是检查屏幕是否打开,所以我只是检查以下结果:

[UIApplication sharedApplication].applicationState == UIApplicationStateActive

知道为什么我会得到零回报吗?

4

1 回答 1

2

OK your code is incorrect (I'm surprised it compiled):

UIApplicationState *applicationState = [UIApplication sharedApplication].applicationState;

Should be:

UIApplicationState applicationState = [UIApplication sharedApplication].applicationState;

(it's an enum not an object).

于 2013-02-22T16:11:54.217 回答