1

My app is Navigation based. UIBarButtonItem on it.

refreshstopButton = [[UIBarButtonItem alloc] 
initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self 
action:@selector(refreshTapped)]; 

I found when I tap on the status bar, "refreshTapped" gets triggered (not caused by my big finger, also reproducible by using simulator and mouse click). Stacktrace shows it comes from

-[UIApplication sendAction:to:from:forEvent:];

I don't understand why. Sometimes my app crashes with very similar stacktrace as Crash on iPhone?

NOTE: I also tried UICatalog sample, I saw the same thing: clicking on the status bar triggers the "Back" UIBarButtonItem action (using simulator).

After playing with the simulator for a while, i realized the sensitive area is much bigger than the button border. I think maybe that is the way Cocoa Touch works.

However the crash problem remain unsolved. According to the stacktrace, looks like it's triggered by a touch of the status bar.

Here is the crash log:

0   libobjc.A.dylib                 0x32da1cb2 objc_msgSend + 42
1   UIKit                           0x324c3a30 -[UIControl(Deprecated) sendAction:toTarget:forEvent:] + 28
2   UIKit                           0x324c3990 -[UIControl(Internal) _sendActionsForEventMask:withEvent:] + 352
3   UIKit                           0x32563764 -[UIControl mouseUp:] + 376
4   UIKit                           0x3254d314 -[UIView(Internal) _mouseUp:] + 32
5   UIKit                           0x3254a480 -[UIWindow _handleMouseUp:] + 108
6   UIKit                           0x3254a8da -[UIWindow _statusBarMouseUp:] + 122
7   UIKit                           0x32680980 -[UIStatusBar touchesEnded:withEvent:] + 320
8   CoreFoundation                  0x328d056a -[NSObject(NSObject) performSelector:withObject:withObject:] + 18
9   UIKit                           0x32406094 forwardMethod2 + 60
10  UIKit                           0x324a04ca -[UIResponder touchesEnded:withEvent:] + 2
11  UIKit                           0x32404bee -[UIWindow _sendTouchesForEvent:] + 362
12  UIKit                           0x32404568 -[UIWindow sendEvent:] + 256
13  UIKit                           0x323ed30c -[UIApplication sendEvent:] + 292
14  UIKit                           0x323ecc4c _UIApplicationHandleEvent + 5084

I also tried to follow http://cocoawithlove.com/2009/05/intercepting-status-bar-touches-on.html to capture event on status bar. But as some other people pointed out, it no longer works in iOS 4.x

Community
  • 1
  • 1
Espina
  • 83
  • 7
  • 1
    Post the declaration code of refreshTapped. – alloc_iNit Sep 06 '11 at 05:29
  • `- (IBAction) refreshTapped { if (self.isRefresh == YES) { [self requestNetworkActivityIndicator]; [self performLoading]; [self releaseNetworkActivityIndicator]; } else { [self.webview stopLoading]; [self releaseNetworkActivityIndicator]; } }` – Espina Sep 06 '11 at 18:24
  • Do you try to comment all code lines in `refreshTapped` method? – Nekto Sep 06 '11 at 18:42
  • I haven't check but set return type of method (void) refreshTapped, instead of IBAction. – alloc_iNit Sep 07 '11 at 06:00
  • +Nekto, I guess it will do nothing. And I doubt it's relevant to the crash I see. – Espina Sep 12 '11 at 00:34

1 Answers1

0

Check & Replace this line to avoid crashing problem.

@selector(refreshTapped:) instead of @selector(refreshTapped)

(notice the extra : in the first alternative)

Mark Seemann
  • 225,310
  • 48
  • 427
  • 736
Nikunj Jadav
  • 3,417
  • 7
  • 38
  • 54