鸿蒙在挂载事件监听器后,过一段时间就会无效 #3167
-
|
class listener implements PAGViewListener { constructor(start: () => void, cancel: () => void, end: () => void, update: () => void,) { @ObservedV2 } constructor(hctx: Context) { } 首次进入调用play会执行PAGViewListener中的所有方法,但是在onAnimationEnd后,我如果不执行任何操作,将手机静置三分钟(不确定),然后我再调用play,此时PAGViewListener中的所有方法不会再触发,这是什么情况;如果没有静置,在onAnimationEnd后调用play是会触发PAGViewListener的 |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
|
为了提高对接效率,此类问题请提供复现 demo,这样解决起来是最快的 |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
|
@qianyunrumo listener 你需要自己强引用,从你提供的描述 viewController.addListener(
new WeakRef<PAGViewListener>(
new listener(
this.start,
this.cancel,
this.end,
this.update
)
)
); |
Beta Was this translation helpful? Give feedback.

@qianyunrumo listener 你需要自己强引用,从你提供的描述
过一段时间就会无效应该是WeakRef被GC释放了