【问题标题】:Adding a UINavigationBar to a UITableView将 UINavigationBar 添加到 UITableView
【发布时间】:2012-12-18 13:58:39
【问题描述】:

I have added a UINavigationBar in the Table view.我知道这不是正确的方法,但我在想还有其他方法吗?当我试图将 UINavigationBar 和表视图放在视图控制器或表视图控制器中时,控制台会出现此错误:

Terminating app due to uncaught exception 'UIViewControllerHierarchyInconsistency',
reason: 'A view can only be associated with at most one view controller at a time!
View <UITableView: 0x1ebfb200; frame = (0 0; 320 480); clipsToBounds = YES; opaque
= NO; autoresize = W+H; gestureRecognizers = <NSArray: 0x1e5a0500>; layer =
<CALayer:0x1e5a94f0>; contentOffset: {0, 0}> is associated with <UITableViewController: 0x1e59f8c0>.
Clear this association before associating this view with <SheetsSavedViewController: 0x1f879660>.'

现在当我滚动时,导航栏会随着表格视图移动。有什么办法可以将其锁定在顶部吗?或者修复上面的错误...

【问题讨论】:

标签: iphone objective-c ios xcode


【解决方案1】:

为什么不使用文件菜单中的菜单选项将整个表格视图控制器嵌入到导航视图中。

【讨论】:

    【解决方案2】:
    • 在 stroyboard 中选择您的 tableView 控制器
    • 编辑器 -> 嵌入 -> 导航控制器

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-07-26
      • 1970-01-01
      • 2014-01-18
      • 1970-01-01
      • 2016-08-27
      • 2015-12-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多