浮动uiview子视图在滚动时消失

Posted

技术标签:

【中文标题】浮动uiview子视图在滚动时消失【英文标题】:floating uiview subview disappears on scrolling 【发布时间】:2011-12-30 01:23:09 【问题描述】:

我有一个UIView 作为子视图添加到我的UITableView.view。它看起来很棒并且工作正常,但是当我滚动我的UITableView 时,子视图被切碎并消失,但只有一部分(主要是滚动关闭的部分)。我可以通过调用使其重新启动:

[self.view bringSubviewToFront:self.myView];

但我宁愿不必在UITableView 滚动时调用它。有什么我做错了吗?提前致谢。

【问题讨论】:

【参考方案1】:

试试这个..

-(UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

static NSString *CellIdentifier = @"CellIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

if (cell == nil)  
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:nil] autorelease];
 

【讨论】:

【参考方案2】:

很难说你的最终目标是什么,但向UITableView 添加子视图有点反直觉。 UITableView 管理它的子视图(UITableViewCell's),它们可能优先于您的子视图。你在找backgroundView吗?

【讨论】:

基本上我想要一个视图悬停在 tableview 上...我实际上是将它添加到 UIView 而不是实际的 tableview。 这是UITableViewController 吗?如果是这样self.view 就是UITableView 如果是这种情况,那么您可能需要改用UIViewController 子类并重新添加UITableViewController 功能。 overview for UITableViewController 可以快速了解 UITableViewController 的功能 我最终没有使用 UITableView 控制器和 UIViewController 来避免滚动...不过感谢您的帮助。

以上是关于浮动uiview子视图在滚动时消失的主要内容,如果未能解决你的问题,请参考以下文章