如何在tableView控制器上添加浮动按钮

时间:2016-08-23 10:54:55

标签: swift uitableview button

我有一个tableView控制器。 我想在YouTube应用中添加一个浮动按钮,例如按钮。 当我拖动按钮时,它在tableView内部,而不是浮动。

1 个答案:

答案 0 :(得分:0)

对于这种情况,你可以在UIViewController中使用UITableView,而不是UITableViewController。 至于你做什么时的UITableViewController

[self.view addSubView:customButton];
//or
[self.tableView addSubView:customButton];

然后它认为你正在向tableView添加一个subView,因为tableViewController主视图是你的tableView。

只需要一个UIViewController并在其中添加UITableView作为子视图,并将customButton作为subView添加到主视图中。

[self.view addSubView:myTableView];
[self.view addSubView:customButton];

或者你总是可以在IB中创建它。 :)