2010年6月6日 星期日

[Iphone] Bug for touch event on hidden status bar place

When I thouch hidden status bar place on iphone simulator.
Something happend that is no thouch event triggered.

So, I search on google, find this is a iphone simulator bug.

On google, I searched this answer.

This behavior only happens in the iPhone Simulator. When I run the application on an actual iPhone, it works fine.

Reference link.

And I found another answer.

- (void)sendEvent:(UIEvent *)anEvent
{
#define GS_EVENT_TYPE_OFFSET 2
#define GS_EVENT_X_OFFSET 6
#define GS_EVENT_Y_OFFSET 7
#define STATUS_BAR_TOUCH_DOWN 1015

// Traverse from the UIEvent to the GSEvent to the type
int *eventMemory = (int *)[anEvent performSelector:@selector(_gsEvent)];
int eventType = eventMemory[GS_EVENT_TYPE_OFFSET];

// Look for status bar touches by event type
if (eventType == STATUS_BAR_TOUCH_DOWN)
{
// The next 6 lines aren't essential but if you want to know where the
// touch coordinates live, here they are:

int xMemory = eventMemory[GS_EVENT_X_OFFSET];
int yMemory = eventMemory[GS_EVENT_Y_OFFSET];

typedef union {int intValue; float floatValue;} Int2Float;
float x = ((Int2Float)xMemory).floatValue;
float y = ((Int2Float)yMemory).floatValue;

NSLog(@"Status bar down at %f, %f", x, y);

// Send a message to the delegate to handle the action
[(HiddenDrawerAppDelegate *)self.delegate toggleDrawer];
}
else
{
[super sendEvent:anEvent];
}
}
Reference Link.

沒有留言:

張貼留言

Hello