Search code examples
iphoneobjective-cipaduiviewnslog

Identifing a UIView with NSLog


I am trying to identifier a touch in the Status Bar of the iPhone/iPad. So, I overloaded UIApplication and in sendEvent, I do the NSLog of a UIView that was clicked. I get this:

   <UIStatusBarForegroundView: 0x4e8b9d0; frame = (0 0; 768 20); alpha = 0.75; autoresize = W; layer = <CALayer: 0x4e8ba90>>

How can I use this for identifier this view? I tried the obvious:

 [touch.view isKindOfClass:[UIStatusBarForegroundView class]]

But, the program didn't find UIStatusBarForegroundView object. The solution is check the frame, because the status bar will always be (0 0; 768 20); and (0 0; 1024 20) for iPad. This is not the beautiful solution, because for iPhone, will have other frame.

There are other best solution for this?


Solution

  • Try using the code below to get the name of the status bar class, and once you know what the status bar returns from this call, then you can use that in a literal string comparison.

    NSString *svClass = NSStringFromClass([touch.view class]);
    

    Once you know what the status bar view returns you can do this:

    if ([svClass:compare @"theclassnameyougetbackfromstatusbar"]== NSOrderedSame) {
    

    Hopefully this will get around the problem of the program not finding the UIStatusBarForegroundView class