現在、iOS SDK 6.0 を使用してアプリケーションを実装していますが、問題があります。
ユーザーがホームボタンをクリックしたことを検出するためにいくつかの NSNotificationCenter を実装した UIViewcontroller を初めて開いたとき、ホームボタンをクリックしてアプリに戻ろうとすると動作しているように見えます。しかし、問題は、私が UIViewcontroller を使用しているときに別の UIViewcontroller に移動し、この UIViewcontroller に戻ってホーム ボタンをクリックしようとすると、アプリがクラッシュしたように見えることです。
これは私のコードです:
In the viewDidLoad function :
[[NSNotificationCenter defaultCenter] addObserver: self
selector: @selector(ApplicationEnteringBackground)
name: UIApplicationDidEnterBackgroundNotification
object: nil];
[[NSNotificationCenter defaultCenter] addObserver: self
selector: @selector(ApplicationEnteringForeground)
name: UIApplicationWillEnterForegroundNotification
object: nil];
そして、私はメソッドに実装しました:
-(void)ApplicationEnteringBackground
{
...
}
-(void)ApplicationEnteringForeground
{
...
}
問題は次のようになります。
助けてくれてありがとう =)