2011-11-01 77 views
0

我正在开发一个使用Appcelerator的iOS应用程序。 在这个应用程序,我有一个主包装视图和一些子视图。我需要使用布局垂直属性将它们置于彼此之下,但它们都堆叠在一堆(而不是单独的“行”)中。如何使用垂直布局?

下面的代码有什么问题?

// Create the padding view 

      container = Ti.UI.createView({ 

       top: 0, 
       left: 0, 
       width: 320, 
       height: 460, 
       backgroundColor: '#000' 

      }); 

      // Create the padding view 

      wrapper = Ti.UI.createView({ 

       top: 0, 
       left: 0, 
       width: 320, 
       height: 'auto', 
       layout: 'vertical' 

      }); 

      // Create the padding view 

      label = Ti.UI.createLabel({ 

       text: e.label, 
       color: e.color, 
       font:{fontSize:36,fontWeight: 'normal'}, 
       top: 10, 
       width: 'auto', 
       height: 'auto' 

      }); 

      // Create the padding view 

      perks_label = Ti.UI.createLabel({ 

       text: 'Lorem Ipsum is', 
       color: '#fff', 
       font:{fontSize:26,fontWeight: 'normal'}, 
       top: 10, 
       left: 10, 
       width: 'auto', 
       height: 'auto' 

      }); 

      // Create the padding view 

      perks_data = Ti.UI.createLabel({ 

       text: 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy text ever since the 1500s, when an unknown printer', 
       color: '#fff', 
       font:{fontSize:12,fontWeight: 'normal'}, 
       top: 10, 
       left: 10, 
       width: 'auto', 
       height: 'auto' 

      }); 

      // Add label to wrapper 

      wrapper.add(label); 

      // Add label to wrapper 

      wrapper.add(perks_label); 

      // Add label to wrapper 

      wrapper.add(perks_data); 

      // Add wrapper to container 

      container.add(wrapper); 

      // Return the row 

      return container; 
+0

我看不出任何代码有问题,并且它在您的Android平台上工作。您是否使用标签的特定高度值进行了尝试?如果Titanium无法计算出会影响自动定位的标签有多高。 – Craig

回答

0

看起来perks_label和perks_data的左上角应该是不同的。尝试将perks_data设置为最高:50。

谢谢,

0

我以前打过这堵墙。你是否将当前窗口的布局设置为“垂直”?因此,从您添加容器的窗口中,将其布局设置为垂直:

var win = Titanium.UI.currentWindow; 
win.layout = 'vertical';