iOS下showToast、hide再show时不显示的临时解决方案

发现问题

标题字数限制,这里较为详细地描述下:
showToast,再hideToast,然后再show另外一个toast。此时实际效果为第1个toast正常显示、正常隐藏,然后就没了

放到实际项目中的问题表现为:
我基于wx.request封装了一个叫做request的公用方法
在调用wx.request前会show一个icon为loading的toast
然后在wx.request的success回调里wx.hideToast()
然后再调用request的回调函数。这时,如果request的回调函数里也有个showToast,那么不好意思,这第二个toast是压根不会显示的

问题追溯

2月份时有人就反馈了这个问题:https://developers.weixin.qq.com/blogdetail?action=get_post_info&docid=48919d1d14ad7c9e207a151dc14d2ae4&highline=show%7C%26hide&token=1908977939&lang=zh_CN
据官方说是修复了,然而PC模拟器和安卓都正常,唯独iOS至今没有修复

不巧今天踩到坑,我打算用wx.showLoading来替代上面说的icon为loading的toast。这样wx.hideLoading跟第二个toast就不冲突了吧?
然而我还是图样了:https://developers.weixin.qq.com/blogdetail?action=get_post_info&docid=d9acd2beaa983f2cdf1cd1871d47d3c4&highline=hide%7C%26show&token=1908977939&lang=zh_CN
是的,你没看错,hideLoading会隐藏掉toast,这个BUG也是至今没修复。也就是说我依然还在坑里

猜测原因

偶然注意到PC模拟器和安卓上的toast、loading的show和hide都没有过渡动画,而iOS上的却有
怀疑是iOS上的过渡动画时间并没有算在duration内,如果在过渡动画期间内调用hide和show,此时toast实例还并没有完全删除,也就导致第二个toast出不来

临时解决方案

那么是否可以用setTimeout来尝试临时解决呢?我一开始延迟100ms,无效。后来逐渐调整到300ms,差不多刚好就是第一个toast渐隐消失完毕后第二个toast就跟着渐隐出现了。至此,这个问题就算是临时解决了

5 条评论

昵称
  1. HomerTem

    It is an excellent post. This site has lots of useful things, it helped me in many ways.
    https://marketingsevilla.es/buy-custom-essays-125/

  2. Gregorynip

    I like to get my inspiration from really meaningful phrases said by truly great people like “History is Philosophy teaching by examples”, do you know where I can find thematic compiltaions of those?

    http://www.fining.eu/powerpoint-presentations-will-likely-at-all-times-12/

  3. RobertJam

    I have seen something similar in some other thread. You will probably find certain parts of that article helpful, not everything obviously, but I think it’s worth looking into.
    http://stevenrgerst.com/fhgbv/47/function.include/page/2

  4. Din

    hello 贵站头像链接GG了…
    http://www.aihoom.com/links.html
    能否重发一个给我=.=

    1. mokeyjay

      你的评论因为带连接被自动丢垃圾箱了hhh
      永久有效头像链接 -> https://cloud.mokeyjay.com/img/headimg.jpg