0

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?

5
  • 1
    What are you trying to do? The status bar is a private object, and already responds to touches. Messing around with it may be reason enough to reject your app from the store. Aug 22, 2011 at 3:37
  • Why exactly do you want to identify a touch in the status bar? There may be callbacks for what you want.
    – Akshay
    Aug 22, 2011 at 6:51
  • @Dave DeLong, I will not sent it for App Store, it is only to start the debug screen. But is good know that I can't do it :P
    – Rodrigo
    Aug 22, 2011 at 21:25
  • @Akshay, I don't find the way to do this, how I get the touch in Status Bar? I found this: cocoawithlove.com/2009/05/… but didn't work. How can I get the touch in status bar in a easy way?
    – Rodrigo
    Aug 22, 2011 at 21:25
  • @Rodrigo it's possible; it's just not a good idea. Aug 22, 2011 at 22:04

2 Answers 2

3

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

0
0

You can assign a tag number to the view:

tag
An integer that you can use to identify view objects in your application.

@property(nonatomic) NSInteger tag
1
  • Not work. This is a system UIView and every system view have tag to 0. I do not create this view.
    – Rodrigo
    Aug 21, 2011 at 21:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.