2

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.

4

3 回答 3

4

This article on cocoawithlove.com is exactly what you want.

From that article:

"The trickiest part of the sample application is detecting a touch in the status bar.

By implementing a custom setContentOffset:animated: method on a UITableView and setting a breakpoint in that method, you can see in the debugger stack that the UIApplication sendEvent: method is invoked for status bar touches, so that's where we'll begin."

于 2009-05-25T16:15:26.553 回答
1

It should be happening automatically unless you set the scrollsToTop property to NO.

于 2009-05-25T16:32:39.547 回答
0

这可能是主要的矫枉过正,但您可以编写自己的状态栏。

您可以通过在应用程序 plist 中将“状态栏最初隐藏”设置为“是”来隐藏实际状态栏。然后在视图顶部创建您自己的自定义状态栏视图,高度为 20px,它可以是 UIButton,也可以是带有 UITapGestureRecognizer 的 UIView。

您可以通过以下方式检测电池电量/状态(充电和插入与否):

UIDevice *myDevice = [UIDevice currentDevice];
[myDevice setBatteryMonitoringEnabled:YES];

float batteryLevel = [myDevice batteryLevel];
UIDeviceBatteryState batteryState = [myDevice batteryState];

您可以通过 [NSDate date] 获取时间;(然后使用 NSDateFormatter 格式化)。

获得信号强度有点不确定,但可以通过一定程度的独创性粗略估计。

于 2011-07-06T23:06:30.627 回答