在UiTableView顶部创build一个button
我想了解Facebook Messenger如何在留在UITableView
之上的屏幕的button上创build一个button,并遵循滚动?
我想实现右下方的蓝色button。 我应该怎么做到这样的事情?
任何推动正确的方向将高度赞赏。
添加叠加视图时有几个途径:
-
作为包装
UINavigationController
的子视图,这意味着它不会滚动表的内容 -
作为只有一个部分的简单样式的
UITableView
的部分页脚 -
作为
UITableView
的子视图,并使用UIScrollViewDelegate
的scrollViewDidScroll:
随着用户滚动表格(不断更新视图的框架)(这使得它看起来不动)
在你的UIViewController子类中执行此操作:
[self.view insertSubview:myButton aboveSubview:self.tableView];
注意:如果你的UIViewController是一个UITableViewController,这个代码可能无法工作,因为UITableViewController把它的表视图作为它的根视图,这使得很多程序员远离它,因为这意味着这个限制。
你可以在你的UITableViewController中轻松做到这一点
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; [appDelegate.window addSubView:myButton];
我试过这个,它为我工作。 祝你好运! 🙂