简体   繁体   English

带有SubView的tableView的容器视图或UIViewController

[英]Container View or UIViewController for tableView with SubView

I have a UIViewController in storyboard that will be a sliding up menu. 我在storyboard UIViewController中有一个UIViewController ,它将是一个向上滑动的菜单。 I want to place it in a UITableView . 我想将其放在UITableView If I place it as subview of UITableView and prevent it from scrolling, it gets the look I want, with one problem, the section headers of tableview scroll above subview. 如果我将其放置为UITableView子视图并阻止其滚动,则它会得到我想要的外观,一个问题是,tableview的节标题在子视图上方滚动。

Now, in order to prevent this behavior, I could reduce tableview frame, but it doesn't work because my subview is inside that same frame, right? 现在,为了防止这种行为,我可以减少tableview框架,但是它不起作用,因为我的子视图在同一框架内,对吗?

So , if that is true, what is the best way to achieve this? 那么,如果这是真的,那么实现这一目标的最佳方法是什么? Place both screens inside a third UIViewController ? 将两个屏幕都放置在第三个UIViewController

Don't try to put other views inside a table view. 不要尝试将其他视图放在表格视图中。 Bad news. 坏消息。

If your table view is managed by a UITableViewController then that's really all you can have in the table view (unless your views are inside cells, or in headers or footers.) 如果您的表格视图是由UITableViewController管理的,那么实际上就是您可以在表格视图中拥有的(除非您的视图位于单元格内部,页眉或页脚中)。

If you ARE using table view controllers to manage your table view(s), I suggest you create a container view on the view controller that needs to contain the table view, then control-drag an embed segue to the table view controller. 如果要使用表视图控制器来管理表视图,建议您在需要包含表视图的视图控制器上创建一个容器视图,然后按住Control键并将嵌入的Segue拖到表视图控制器上。 That way the table view controller becomes a child view controller of the main VC, and you can put other view elements on the screen to your heart's content. 这样,表视图控制器就成为主VC的子视图控制器,并且您可以将其他视图元素放在屏幕上以显示您的内心。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在UIViewController视图上对子视图进行动画处理 - Animate subview on UIViewController view UIViewController作为其他视图控制器的子视图 - UIViewController as a subview for other view controllers 将UIViewControllers视图添加为另一个UIViewController视图的子视图 - Add UIViewControllers View as a subView of another UIViewController view 将子视图添加到UIImageView,它是IB中UIViewController的视图出口 - Add a subview to a UIImageView that is the view outlet of a UIViewController in IB 如何将UIViewController的视图作为子视图添加到UITableViewCell? - How to add a UIViewController's view as a subview to a UITableViewCell? 在UIView中作为子视图调用UIViewController视图时出现问题 - Issue in calling UIViewController view as subview in UIView 如何将NSMutableArray数据从UIViewController传递到TableView子视图 - How to pass NSMutableArray data from a UIViewController to a TableView subview 子视图未使用容器的完整视图 - Subview is not using full view of container 以编程方式将 UIViewController 加载到容器视图中 - Loading a UIViewController into a Container View programmatically 确定UIViewController是否在Container View中 - Determine if UIViewController is inside Container View
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM