Hi, I am using titanium sdk version 2.1.0.GA IOS simulator host operating system is MacOS. Titanium Studio, build: 2.1.0.201206251749. i am trying to add a button to all the views that are in scrollableview. The button does not appear. please help .Below is my code.Thanks in advance.
var startedScrollView = Titanium.UI.createScrollableView({ showPagingControl : true, backgroundImage : 'ui/common/images/background.png', scrollingEnabled : false, exitOnClose : true }); var startedView1 = Ti.UI.createView({ top : 0, width : Ti.Platform.displayCaps.platformWidth, height : '100%', }); var startedView2 = Ti.UI.createView({ top : 0, width : Ti.Platform.displayCaps.platformWidth, height : '100%', }); var getStartedButton = Ti.UI.createButton({ title : 'Get Started', color : '#000000', text : 'GetStarted', width :100, height: 40, bottom: 0, align : 'center' }); getStartedButton.addEventListener('click', function(e) { sleep(2000); clearInterval(intervalTimer); Ti.include('ui/common/activibeViews/Login.js'); firstwin.close(); }) startedView1.add(getStartedButton); startedView2.add(getStartedButton); infoViewArray.push(startedView1); infoViewArray.push(startedView2); startedScrollView.views = infoViewArray; win.add(startedScrollView); win.open();
3 Answers
Accepted Answer
Cannot add the same button object to multiple parents.
You could build a Constructor function and add a 'new' object based upon the Constructor to each view.
try removing this bottom: 0 and see what happens
The button should actually appear on the second screen. The reason is because you can't reuse elements like that. You need to create a factory method that creates a new button for each view.
Your Answer
Think you can help? Login to answer this question!