如何将pickerColumn的宽度调整为pickerColumns内部的文本? [英] How can I adjust the width of a pickerColumn to the text inside the pickerColumns?

查看:269
本文介绍了如何将pickerColumn的宽度调整为pickerColumns内部的文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

到目前为止,我只能通过代码手动调整每个PickerColumn的大小,但是我希望它们中的每一个都可以根据它们中最大的PickerRow中的内容自动进行调整. 这是因为我正在使用动态PickerColumns,其PickerRows内容会根据前一个PickerColumn的选定值而变化.我发现了如何使用下一个代码扩展整个Picker:

So far I can only adjust the size of each PickerColumn manually through code, but I want each of them to adjust automatically according to the contents from the largest PickerRow inside of any of them. This is because I'm working with dynamic PickerColumns whose PickerRows content change according to the previous PickerColumn's selected value. I found out how to scale the whole Picker using the next code:

var transformPicker=Ti.UI.create2DMatrix().scale(0.5);
var picker = Ti.UI.createPicker({
    width:500,
    height:10,
    top:0,
    transform:transformPicker
});

我试图将转换矩阵应用于PickerColumn,但是它什么也没做.有人知道如何调整尺寸吗?还是我要调整错误的尺寸?

I tried to apply a transformation matrix to a PickerColumn but it didn't do anything. Does anybody know how to adjust the size of them? Or am I trying to resize the wrong thing?

在此先感谢您能给我的任何建议,我是在Titanium中开发iOS的新手,尽管不难习惯其API,但真正的问题是像我这样的小技巧.正在尝试弄清整个过程有点令人困惑.

Thanks in advance for any piece of advice you can give me, I'm new to developing for iOS in Titanium and even though is not hard to get used to its API, the real issue are the small tricks like the one I'm trying to figure out that makes the whole thing kinda confusing.

推荐答案

如果您使用的转换很可能会遭到Apple的拒绝,因为这是Apple特定的UI元素,因此任何严重调整其大小的行为都将受到侵犯人机界面指南.如果发现屏幕宽度的列过多,则可能需要放弃Picker元素:-(或面对Apple的愤怒.

If you use a transform that could very well get you a rejection from Apple, since this is a Apple Specific UI element, so any egregious resizing of it will violate the Human Interface guidelines. If you find that you have too many columns for the screen width, then you may need to abandon the Picker element :-( or face Apple's wrath.

但是要回答有关动态调整选择器列大小的问题,只需使用选择器的 reloadColumn(Titanium.UI.PickerColumn column)方法.这将根据选择器的大小和行内容来调整大小.还可以考虑使用PickerColumn的 updateLayout(Dictionary params).

But to answer your question about dynamic resizing of picker columns, just use the reloadColumn( Titanium.UI.PickerColumn column ) method of the picker. This will resize based on picker size and row contents. Also consider using updateLayout( Dictionary params ) of the PickerColumn.

在此处查看文档

这篇关于如何将pickerColumn的宽度调整为pickerColumns内部的文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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