当前位置: 动力学知识库 > 问答 > 编程问答 >

objective c - Detect if UIViewController changed in UI hierarchy in iOS

问题描述:

Is there a way to detect if anything changes on UIViewController (current view) in the whole UI hierarchy?

I would like to shut off a certain service at background when user have touch/trigger any event in current view without knowing what interaction user provided. For example, I have a network service running at background when user first land on the view, if they swipe or navigate to other page, i need to close the service before the view changes happen.

网友答案:

If your views number is changing you can simply use

        self.view.subviews

to check it after your operation.

If you just want to test when you first show or leave you can use ViewDidAppear() or ViewDidDisappear() to check you operation as Teja said.

分享给朋友:
您可能感兴趣的文章:
随机阅读: