In iOS
, programmatically, how can one find what top most UIView
is?
In other words .. what view is displayed right now?
Say, i have a nib with 3 views stacked on top of one another. Inside a program, i can remove the top view if I know what it is. How can i find out what view is on top of the nib?
You can have a lot of top most views because a view doesn't have to take all the screen.
If you want the top most subview of a view, you can call
[yourView subviews];
and take tje last one (they are in displayed order, most front last)
[[yourView subviews] objectAtIndex:[[yourView subviews] count]];
edit: this is better (from comments)
[[yourView subviews] lastObject];
If you know your displayed viewController just replace yourView by yourController.view
Like this
UIView *topMost = [[self.view subviews] lastObject];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With