在 UITableViewController 中滚动显示 Toast 消息 [英] Show Toast message in UITableViewController with scroll

查看:37
本文介绍了在 UITableViewController 中滚动显示 Toast 消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于 Toast 消息,我在 Swift 5、Xcode 11 中使用 Toast-Swift来自:Toast-Swift

For the Toast message I am using Toast-Swift in swift 5, Xcode 11 from: Toast-Swift

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

But I have a problem with UITableViewController, when TableView has scroll, the message is displayed off the screen and the user cannot see the message.

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

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

I appreciate your help to show the message correctly on screen. Regards.

推荐答案

在 table view 的 superview 中呈现 toast,而不是在 table view 本身中.如果您使用导航控制器,这将是: self.navigationController?.view.makeToast("This is a piece of toast") 或者您可以直接使用窗口(尽管我不会不推荐这个):self.view.window?.makeToast("This is a piece of toast")

Present the toast in the table view's superview, instead of in the table view itself. If you're using a navigation controller this would be: self.navigationController?.view.makeToast("This is a piece of toast") or alternatively you could use the window directly (although I wouldn't recommend this): self.view.window?.makeToast("This is a piece of toast")

另外,我强烈建议使用 UIViewcontroller 代替,因为 UItableViewContoller 有这个问题 self.view == self.tableview 并导致滚动出现这个问题

Also, I highly recommend using a UIViewcontroller instead as UItableViewContoller has that problem self.view == self.tableview and cause this problem with scroll

这篇关于在 UITableViewController 中滚动显示 Toast 消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆