如何检测 iPhone 状态栏中的触摸?
我有一个 UITableview,当触摸状态栏时我想滚动到顶部。
我希望找到一个可以收听的通知,然后使用 tableview:scrollToRowAtIndexPath: 进行滚动,但找不到。
有没有办法做到这一点?
[更新]
网上查了一些,我怀疑这是模拟器咬我的。 我的 UIScrollView 无法在模拟器中滚动到顶部,但我还没有在硬件上尝试过。 另外,我有一个 UIScrollView,还有 UITextView,所以我想知道这是否正在吞噬它。
我将看看我能用scrollsToTop 做什么。
I have a UITableview that I would like to scroll to the top when the status bar is touched.
I expected to find a notification that I could listen to and then use tableview:scrollToRowAtIndexPath: for the scroll, but can find none.
Is there a way to do this?
[Update]
Finding some more on the net, I am suspicious that this is the simulator biting me. My UIScrollView is failing to scroll to the top in the simulator, but I have not tried on hardware. Also, I have one UIScrollView, but also UITextView, so I wonder if that is eating it.
I will see what I can do with scrollsToTop.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这篇文章 cocoawithlove.com 正是您想要的。
摘自那篇文章:
This article on cocoawithlove.com is exactly what you want.
From that article:
除非您将scrollsToTop 属性设置为NO,否则它应该自动发生。
It should be happening automatically unless you set the scrollsToTop property to NO.
这可能有点矫枉过正,但您可以编写自己的状态栏。
您可以通过在应用程序 plist 中将“状态栏最初隐藏”设置为 YES 来隐藏实际状态栏。 然后在视图顶部创建您自己的自定义状态栏视图,高度为 20px,它可以是 UIButton,也可以只是带有 UITapGestureRecognizer 的 UIView。
您可以通过以下方式检测电池电量/状态(充电和是否已插入):
您可以通过 [NSDate date] 获取时间; (然后使用NSDateFormatter进行格式化)。
获取信号强度有点不确定,但可以在一定程度上粗略估计独创性。
This might be major overkill, but you could write your own status bar.
You can hide the actual status bar by setting the "Status bar is initially hidden" to YES in your application plist. Then create your own custom status bar view at the top of the view with height 20px that is either a UIButton or simply a UIView with a UITapGestureRecognizer.
You can detect battery level/state (charge and plugged-in or not) with:
You can get the time with [NSDate date]; (then use NSDateFormatter to format).
Getting the signal strength is a little iffy but can be roughly estimated with a certain degree of ingenuity.