원하지 않는 경우 다소 오래된 모듈을 사용하여 종속성을 만들 당신이 이것을 시도 할 수 :
새 파일을 작성하고 당신이 원하는대로 호출,이 예를 들어 yourview.js
를 사용했다. 거기에 다음 코드를 붙여 :
module.exports = {
view: Ti.UI.createView({
layout: 'vertical',
backgroundColor: '#ddd',
button: Ti.UI.createButton({ title: 'blur all textfields' }),
textfields: [
Ti.UI.createTextField({ value: 'first' }),
Ti.UI.createTextField({ value: 'second' }),
Ti.UI.createTextField({ value: 'third' }),
Ti.UI.createTextField({ value: 'fourth' }),
]
}),
construct: function()
{
var self = this;
self.view.button.addEventListener('click', function(){
for(var i in self.view.textfields)
self.view.textfields[i].blur();
});
// Add textfields to view
for(var i in self.view.textfields)
self.view.add(self.view.textfields[i]);
// Add button to view
self.view.add(self.view.button);
return self.view;
}
};
yourview.js
파일은 당신이 특정 뷰에 표시 할 모든 것을 포함하고 있습니다. 당신이 모든 것을 가지고이 방법은 당신이 테스트를 별도의 파일 :
에서 원하는
var win = Ti.UI.createWindow({
yourview: require('namespace/ui/yourview').construct()
});
// Add your reference to the scope of the Window object
win.add(win.yourview);
win.open();
// If you want to get the value of the textfields in this scope just use it like this:
Ti.API.info(win.yourview.textfields[0].value);
을 : 당신은 다음과 같이됩니다 Window 객체에서보기를 사용하려고 할 때 구축물 기능은 모든 것을 함께 추가됩니다 Ti.5.4.0 SDK가 포함 된 iOS 9.3 시뮬레이터에서 작동합니다.
감사합니다,하지만 모듈은 아직 6.0.3 – WhiteLine
오래된입니까? 그것은 한 기본 방법 단지 래퍼 : '' - (ID) 감추기 (ID) 인수 { dispatch_sync (dispatch_get_main_queue()^{ UIWindow * 윈도우 = [[UIApplication sharedApplication] keyWindow]; UIView * topView = window.rootViewController.view; [topView endEditing : 예]; }); } – danny005
는 소스 코드를 들여다나요 최신 티타늄 SDK와 잘 작동 – danny005