问题
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
});
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?
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.
回答1:
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.
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.
Check the documentation here.
来源:https://stackoverflow.com/questions/11888240/how-can-i-adjust-the-width-of-a-pickercolumn-to-the-text-inside-the-pickercolumn