使用滚动在 UITableViewController 中显示 Toast 消息

Show Toast message in UITableViewController with scroll

Toast消息我用的是Toast-Swift in swift 5, Xcode 11 来自:Toast-Swift

但是我的 UITableViewController 有问题,当 TableView 滚动时,消息显示在屏幕外,用户看不到消息。

// basic usage
self.view.makeToast("This is a piece of toast")

感谢您帮助我在屏幕上正确显示消息。 问候。

在 table 视图的父视图中显示 toast,而不是在 table 视图本身中。如果您使用的是导航控制器,这将是:self.navigationController?.view.makeToast("This is a piece of toast") 或者您可以直接使用 window(尽管我不推荐这样做):self.view.window?.makeToast("This is a piece of toast")

此外,我强烈建议使用 UIViewcontroller,因为 UItableViewContoller 有这个问题 self.view == self.tableview并用 scroll

引起这个问题