UIComponent 扩展类未显示 UIComponent 扩展类 [英] UIComponent extended class isn't showing UIComponent extended class

查看:26
本文介绍了UIComponent 扩展类未显示 UIComponent 扩展类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 1 个表示组件的类(即扩展 UI 组件).在那个组件中,我创建了另一个也是 UIComponent 的类的不同实例,但是这个类没有出现在第一类中.我看到它正在运行并且它具有正确的高点,但我觉得它没有出现在这个高点上.如果我跟踪我看到宽度和高度是 200 X 200 但我的组件中仍然没有任何可见的内容

I have 1 class (that is extending a UIcomponent) that is representing a component. In that component I create different instances of another class that is also a UIComponent but this class doesn't show up in de first class. I see that it is running and that it has the correct hights but I got the feeling that it doesn't show up with this hights. If I trace I see the width and height is 200 X 200 but there is still nothing visible in my component

我敢打赌这个问题有一个简单的解决方案吗?

I bet there is a simple solution for this problem?

推荐答案

如果直接扩展 UIComponent,则必须确保覆盖所有正确的方法,包括 createChildrenupdateDisplayListmeasure.如果您错过了其中任何一个,它将无法正常工作.

If extending UIComponent directly, you have to make sure to override all the right methods, including createChildren, updateDisplayList, and measure. If you miss any of those it won't work.

记得在createChildren中addChild,在updateDisplayList中设置x、y、width、height,在measure中设置自己的测量属性.

Remember to addChild in createChildren, to set x, y, width, and height in updateDisplayList, and to set your own measured properties in measure.

通过在一个 UIComponent 中设置所有内容"来修复"它可能不是正确的想法.

"Fixing" it by "setting everything in one UIComponent" is probably not the right idea.

也就是说,将东西放入画布通常比扩展 UIComponent 容易得多.默认情况下,所有内容都会显示,您无需覆盖任何内容.我只在做一些非常有趣的事情或者我想要自定义控件时才扩展 UIComponent

That said, it's usually A LOT easier to just put stuff into a canvas instead of extending UIComponent. Everything will show up by default, and you don't have to override anything. I only extend UIComponent when I'm doing something really fancy or I want custom control

这篇关于UIComponent 扩展类未显示 UIComponent 扩展类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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