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

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

问题描述

到目前为止,我只能通过代码手动调整每个 PickerColumn 的大小,但我希望每个 PickerColumn 都能根据其中任何一个 PickerRow 中最大的 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天全站免登陆