[英]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.