简体   繁体   English

使UIView固定在UITableViewController的顶部

[英]Make UIView fix position to the top of UITableViewController

I want to make custom Navigation Bar using UIView but I don't want to embed Navigation Controller. 我想使用UIView制作自定义导航栏,但是我不想嵌入导航控制器。 I have tried making UIView but end up the UIView is scrollable. 我尝试过制作UIView,但最终UIView是可滚动的。 The main thing about Navigation Bar is sticked to the top whether the UITableViewController scrolled or not. 无论UITableViewController是否滚动,导航栏的主要内容始终位于顶部。 How to make the custom Navigation Bar with UIView has fixed position like the original navigation bar. 如何使用UIView制作自定义导航栏与原始导航栏一样具有固定的位置。 Thanks! 谢谢!

Instead of using a UITableViewController, you should probably use a regular UIViewController and then add a UITableView and your custom UIView as subviews. 代替使用UITableViewController,您可能应该使用常规的UIViewController,然后添加UITableView和自定义UIView作为子视图。 UITableViewControllers aren't very flexible when it comes to adding subviews. 当添加子视图时,UITableViewControllers不是很灵活。 They are meant to take up the entire screen. 它们是要占据整个屏幕的。

For static table views you need to add a UITableViewController as a Container ViewController to another UIViewController. 对于静态表视图,您需要将UITableViewController作为容器ViewController添加到另一个UIViewController。 So you will have one main UIViewController that has your custom UIView nav bar and a Container View Controller that holds your UITableViewController. 因此,您将拥有一个具有自定义UIView导航栏的主UIViewController和一个容纳UITableViewController的容器视图控制器。

Simply Create Table Header View. 只需创建表标题视图。 1.Using Table View Delegate Methods Create Header View Programatically of the Starting Cell. 1.使用表视图委托方法以编程方式创建起始单元格的标题视图。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM