黑色半透明导航栏/UITableView/内容插入/滚动位置问题
我正在实现一个 UITableView,它具有右侧尺寸的索引以及节标题。我本质上是在实现一个股票 NSFetchedResultsController,如苹果文档中所述。 UITableView 包含在带有黑色半透明导航栏的 UINavigationController 中。我将顶部内容和滚动条插图设置为 44,以补偿表格的导航栏重叠。即使设置了插图,我在黑色半透明导航栏中使用 UITableView 时也遇到了一些问题,我认为这些问题是相关的。
当我触摸索引列中的某个项目将我带到该部分时,部分标题“悬挂”在正确的位置(在导航栏正下方对接),但第一个单元格似乎向上移动了一个。我认为表格不知道导航栏重叠,因此它会将第一个单元格定位在标题位于窗口框架顶部但标题下方的位置(如果有意义的话)。这很难解释,所以我附上一张屏幕截图来帮助说明。隐藏的第一个“Billy”应该位于节标题“B”下方齐平的第二个 Billy 的位置。
(哎呀,菜鸟太大了,无法发布图片。http://dontgoplasty.com/temp/uitableview。 png )
第二个问题与同一个表有关,但与 selectRowAtIndexPath:animated:scrollPosition: 有关。如果我尝试使用“UITableViewScrollPositionNone”作为“scrollPosition”并将indexPath设置为当前可见屏幕下方的内容,它会将表格向下移动(如预期),但短于我假设的44像素。同样,我认为表格认为单元格在视图中,但没有考虑插图。
希望我只是忽略了一个简单的属性。
感谢您抽出时间
I'm implementing a UITableView that has the index along the right hand size as well as section headers. I'm essentially implementing a stock NSFetchedResultsController as depicted in Apple's docs. The UITableView is contained within a UINavigationController with a Black Translucent Nav Bar. I have the top content and scroller insets set to 44 to compensate for the Nav Bar overlap of the table. Even with the insets set, I'm having a few problems using a UITableView in a Black Translucent Nav Bar which I believe are related.
When I touch an item in the index column to bring me to that section, the section header 'hangs' at the correct spot (butted up right below the nav bar) but the first cell appears to be shifted up one. I'm thinking the table isn't aware of the nav bar overlap, so it's positioning the first cell where it would go if the header was at the top of the window frame but below the header (if that makes sense). It's difficult to explain so I'm attaching a screenshot to help illustrate. The first 'Billy' that's hidden should be in the location of the second billy that's flush below the section header 'B'.
(oops, too big of a noob to post images. http://dontgoplastic.com/temp/uitableview.png )
The second issue has to do with the same table but in regards to selectRowAtIndexPath:animated:scrollPosition:. If I try to use 'UITableViewScrollPositionNone' for 'scrollPosition' and set the indexPath to something that's below the current visible screen, it shifts the table down (as expected), but short what I'm assuming is 44 pixels. Again, I think the table thinks that the cell is in view, but isn't taking into account the inset.
Hopefully I'm just overlooking a simple property.
Thanks for your time
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我仍然不是 100% 出了问题,但我可以通过子类化 UITableView 并编辑 setContentOffset:animated: 来纠正它,如下所示:
- (void)setContentOffset:(CGPoint)contentOffsetAnimated:(BOOL)animated {
CGPoint newOffset = CGPointMake(contentOffset.x, contentOffset.y - 44);
[super setContentOffset:newOffsetAnimated:animated];
}
希望这可以帮助阐明我的问题或帮助其他人找到可能的解决方案。
谢谢。
I'm still not 100% what's going wrong, but I'm able to correct it by subclassing UITableView and editing setContentOffset:animated: like so:
- (void)setContentOffset:(CGPoint)contentOffset animated:(BOOL)animated {
CGPoint newOffset = CGPointMake(contentOffset.x, contentOffset.y - 44);
[super setContentOffset:newOffset animated:animated];
}
Hope this either helps shed some light on my problem or helps someone else out with a possible solution.
Thanks.