我试图在加载窗口后更改选取器行。选择器是在xml file
中创建的,但是当尝试向其添加一行时会引发错误(参见下文)。
如果添加了选择器,我如何添加选择器行?
view.xml用
<!-- other parent views above -->
<Picker id="languagePicker" selectionIndicator="true" useSpinner="true"
width="Ti.Platform.displayCaps.platformWidth" right="0">
</Picker>
view.js
var languages = db.execute("SELECT * FROM language");
while(languages.isValidRow()){
$.languagePicker.add(Ti.UI.createPickerRow({title:languages.fieldByName('language')}));
languages.next();
}
错误日志:
[错误]应用程序崩溃时出现未捕获的异常&#39; NSInvalidArgumentException&#39;。 原因: - [NSNull rangeOfCharacterFromSet:]:无法识别的选择器发送到实例0x109f28af0 堆栈跟踪: 0 CoreFoundation 0x0000000109d03e4d exceptionPreprocess + 141 1 libobjc.A.dylib 0x00000001096d5deb objc_exception_throw + 48 2 CoreFoundation 0x0000000109d0c48d - [NSObject(NSObject)doesNotRecognizeSelector:] + 205 3 CoreFoundation 0x0000000109c5990a ___ forwarding _ + 970 4 CoreFoundation 0x0000000109c594b8 _CF_forwarding_prep_0 + 120 5 UIKit 0x0000000106466d9c - [UILabel _contentInsetsFromFonts] + 137 6 UIKit 0x0000000106782a84 - [_ UILabelLayer updateContentInsets] + 127 7 UIKit 0x0000000106782b73 - [_ UILabelLayer updateContentLayerSize] + 50 8 UIKit 0x0000000106782ce1 - [_ UILabelLayer layoutSublayers] + 25 9 QuartzCore 0x000000010875fe70 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366 10 QuartzCore 0x000000010875fcee _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24 11 QuartzCore 0x0000000108754475 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 277 12 QuartzCore 0x0000000108781c0a _ZN2CA11Transaction6commitEv + 486 13 QuartzCore 0x000000010878237c _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 92 14 CoreFoundation 0x0000000109c2f367 CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION + 23 15 CoreFoundation 0x0000000109c2f2d7 __CFRunLoopDoObservers + 391 16 CoreFoundation 0x0000000109c24f2b __CFRunLoopRun + 1147 17 CoreFoundation 0x0000000109c24828 CFRunLoopRunSpecific + 488 18 GraphicsServices 0x000000010b04bad2 GSEventRunModal + 161 19 UIKit 0x00000001061f9610 UIApplicationMain + 171 20 ISTQB 0x0000000104320de6 main + 310 21 libdyld.dylib 0x000000010a95192d start + 1
答案 0 :(得分:0)
PickerRow
方法需要一组var data = [],
picker = Ti.UI.createPicker();
data.push(
Ti.UI.createPickerRow({
title: 'Row 1'
}));
data.push(
Ti.UI.createPickerRow({
title: 'Row2'
}));
picker.add(data);
个对象。这适用于我的应用程序:
{{1}}
请参阅http://docs.appcelerator.com/platform/latest/#!/api/Titanium.UI.Picker-method-add