2011-11-01 78 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';