UITableView navigationController 部分索引在导航标题后对齐
在带有索引的 UITableView 部分中,如何使所选部分的标题(通过按部分索引)在屏幕的最顶部对齐(_not_)(在导航控制器下) )而是在顶部的导航栏标题之后齐平?
像这样:
[button] Navigation Bar Header at top of screen [other button]
X (section letter)
items within section....
需要明确的是,我遇到的问题是,当在右侧按下某个部分索引时,表格会将该部分滚动到屏幕的最顶部, >隐藏在导航栏下方。我希望该节标题正好在导航标题之后接触导航栏底部边框与节的顶部字母行 - 例如,当表格首次出现时。
In a Section Indexed UITableView how do you make the title of the section chosen (by pressing the Section Index) align _not_ at the very top of the screen (under the navigation controller) but rather flush after the Navigation Bar Header at the top?
like this:
[button] Navigation Bar Header at top of screen [other button]
X (section letter)
items within section....
To be clear, the problem I am having is that when a section index is pressed on the right, the table scrolls that section to the very top of the screen, hidden underneath the navigation bar. I want that section header precisely after the navigation header touching the Navigation Bar bottom border with the top of the Section Letter row - as it is for example, when the table first appears.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
更好的解决方案:
a) 睡一会儿。
b) 意识到,当您睡觉时,'UIBarStyleBlackTranslucent' 的使用已弃用,因此只需执行以下操作:
在你的 UITableViewController 类文件中,写入
c) 别再感到尴尬了,而是意识到睡眠现在是你的武器库中一种更有用的编码技术。 ;p
The clues to the correct solution:
请参阅:developer.apple.com/iphone/library/featuredarticles/ViewControllerPGforiPhoneOS/NavigationControllers/NavigationControllers.html
请参阅:developer.apple.com/iphone/library/documentation/UIKit/Reference/UINavigationBar_Class/Reference/UINavigationBar.html#//apple_ref /occ/instp/UINavigationBar/半透明
http://developer.apple.com/ iphone/library/documentation/uikit/reference/UIKitDataTypesReference/Reference/reference.html
BEFORE SLEEPING, fixed it "The Hard Way"...
请注意,失败方法包括:
使用 Interface Builder 将 UITableView 嵌入到 UIView 中。不起作用,因为它全部自动调整到完整高度。
调整大小 [self.tableView superview].frame = CGRectInset([self.tableView superview].frame, 44, 44);
或者 .bounds 没有效果,
self.tableView.frame 和 .bounds 都没有。
当我尝试时,出现了问题的线索:
self.navigationController.view.frame = CGRectInset(self.navigationController.view.frame, 20, 44);
这实际上改变了其中包含表的视图的大小。显然,将子视图更改为该子视图可以解决原始问题。
用上面的方法修复了它。尽管在后退或前进到其他屏幕之前,更改需要恢复正常,以避免将元素移动到其他地方。
Better solution:
a) Get some sleep.
b) Realize that, while you were sleeping, the use of 'UIBarStyleBlackTranslucent' has been deprecated, so simply do this instead:
In your UITableViewController class file, write
c) Stop feeling embarrassed and instead realize how sleep is now one more useful coding technique in your arsenal. ;p
The clues to the correct solution:
see: developer.apple.com/iphone/library/featuredarticles/ViewControllerPGforiPhoneOS/NavigationControllers/NavigationControllers.html
see: developer.apple.com/iphone/library/documentation/UIKit/Reference/UINavigationBar_Class/Reference/UINavigationBar.html#//apple_ref/occ/instp/UINavigationBar/translucent
http://developer.apple.com/iphone/library/documentation/uikit/reference/UIKitDataTypesReference/Reference/reference.html
BEFORE SLEEPING, fixed it "The Hard Way"...
Note that failed approaches included:
Using Interface Builder to embed the UITableView inside a UIView. Did not work because it all got automatically sized to the full height.
Resizing [self.tableView superview].frame = CGRectInset([self.tableView superview].frame, 44, 44);
or .bounds had no effect,
neither did self.tableView.frame nor .bounds.
The clue to what was wrong came when I tried:
self.navigationController.view.frame = CGRectInset(self.navigationController.view.frame, 20, 44);
which actually changed the size of the view with the table in it. Clearly, changing the subview to that would fix the original problem.
Fixed it with the approach further above. Although before moving back or forward to other screens changes need to be reverted to normal to avoid shifting elements elsewhere.