Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add screen information to frame time #35

Open
Serchinastico opened this issue Jun 9, 2017 · 1 comment
Open

Add screen information to frame time #35

Serchinastico opened this issue Jun 9, 2017 · 1 comment
Assignees

Comments

@Serchinastico
Copy link
Contributor

Serchinastico commented Jun 9, 2017

Theoretically, we should be able to get the current view controller being presented by calling something like:

NSString *viewControllerName = NSStringFromClass([[UIApplication sharedApplication].keyWindow.rootViewController class]);

Additionally, we can subscribe with KVO to the key window, its root view controller and if we want to, to changes in any navigation/page controller in the hierarchy.

@Serchinastico Serchinastico self-assigned this Jun 9, 2017
@Serchinastico
Copy link
Contributor Author

More information on this, UIKit is not KVO compliant and if you find something that is, you might find that it won't in the future so that's the end of the road.

There is a UIWindowDidBecomeKeyNotification notification that is sent when the key window changes, from that we can store the window and ask from time to time the current view controller by traversing the VC hierarchy. It's not very reliable but it's the best we can do.

Apart from that, UIPageViewControllers don't always hold the current page in a public property so information might be just wrong and we can only do a guess by reading its viewControllers array property.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant