UITableView 的范围栏像 App Store 一样吗?
有谁知道如何向 UITableView
添加范围栏? App Store 应用程序有时会执行此操作,如下图所示。
我想使用此范围栏为 UITableView
中的元素添加排序选项。这比使用带有 UISegmentControl
的工具栏更方便。
我只是不知道如何实现这一点。我什至不知道该元素的名称(我将其称为范围栏,因为它看起来就像 UISearchBar
的范围栏,但事实并非如此)。
Does anyone know how to add a scope bar to a UITableView
?
The App Store app does this sometimes, like in the picture below.
I would like to use this scope bar to add sorting options for the elements in the UITableView
. This would be more convenient than having a toolbar with a UISegmentControl
.
I just don't know how to implement this. I don't even know the name of the element (I'm calling it scope bar because it looks just like the scope bar of a UISearchBar
, but it is not).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
实际上,与其他人所说的不同,此 UISegmentedControl 的
.segmentedControlStyle
属性设置为未记录的值 7。但是 @Macatomy 的答案对 AppStore 更安全(尽管 Apple 无论如何也无法检测到这一点)。
Actually, unlike what others have said, this UISegmentedControl's
.segmentedControlStyle
property is set to an undocumented value of 7.But @Macatomy's answer is more AppStore-safe (although Apple can't detect this anyway).
也许您已经解决了这个问题,但我相信这对其他人会有帮助。
在 TableViewController 中使用的 ViewController 中,您应该插入以下代码:
}
这会插入一个分段控件作为表头,当您到达列表顶部时(如果您愿意)它也会弹起,同时始终会弹起当您在列表中滚动时保持可见。
希望有帮助。
Probably you already solved this issue but I believe this can be helpful for other people.
Inside your ViewController that you use in that TableViewController, you should insert the following code:
}
That inserts a segmented control as the table header, which (if you wish) will also bounce when you reach the list top and at the same time will always remain visible while you scroll in your list.
Hope it helps.
该元素是 UISegmentedControl ,
UISegmentedControlStyleBar
样式。您可以设置tintColor
属性来获取所需的颜色。只需将视图放在表格视图上方,您就可以获得类似于屏幕截图的内容。The element is a UISegmentedControl with the
UISegmentedControlStyleBar
style. You can set thetintColor
property to get the color desired. Just put the view above the table view and you can get something that looks like that screenshot.UISegmentedControl
您创建它,设置建立其段,并设置其代表。然后,每当选定的段发生变化时,代理就会采取某种操作。
UISegmentedControl
You create it, set up its segments, and set its delegate. The delegate then takes some sort of action every time the selected segment changes.