【问题标题】:crash on touching the status bar触摸状态栏时崩溃
【发布时间】:2011-09-06 05:13:55
【问题描述】:

我的应用是基于导航的。 UIBarButtonItem 就可以了。

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

我发现当我点击状态栏时,“refreshTapped”被触发(不是由我的大手指引起的,也可以通过使用模拟器和鼠标单击来重现)。 Stacktrace 显示它来自

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

我不明白为什么。有时我的应用程序崩溃,堆栈跟踪与Crash on iPhone?

非常相似

注意: 我还尝试了 UICatalog 示例,我看到了同样的事情:单击状态栏会触发“返回”UIBarButtonItem 操作(使用模拟器)。

在玩了一段时间模拟器后,我意识到敏感区域比按钮边框要大得多。我想这可能就是 Cocoa Touch 的工作方式。

但是,崩溃问题仍未解决。根据堆栈跟踪,看起来它是由触摸状态栏触发的。

这是崩溃日志:

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

我也尝试关注http://cocoawithlove.com/2009/05/intercepting-status-bar-touches-on.html 来捕捉状态栏上的事件。但正如其他人指出的那样,它不再适用于 iOS 4.x

【问题讨论】:

  • 贴出refreshTapped的声明代码
  • - (IBAction) refreshTapped { if (self.isRefresh == YES) { [self requestNetworkActivityIndicator]; [self performLoading]; [self releaseNetworkActivityIndicator]; } else { [self.webview stopLoading]; [self releaseNetworkActivityIndicator]; } }
  • 你尝试注释refreshTapped方法中的所有代码行吗?
  • 我没有检查但设置了方法的返回类型(void)refreshTapped,而不是IBAction。
  • +Nekto,我猜它什么都不会。我怀疑这与我看到的崩溃有关。

标签: iphone ios crash uistatusbar


【解决方案1】:

检查并替换此行以避免崩溃问题。

@selector(refreshTapped:) 而不是@selector(refreshTapped)

(注意第一个选项中额外的:

【讨论】:

  • 他不需要写:,因为他的方法没有接收任何参数。
猜你喜欢
  • 2013-01-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-05-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多