Titanium 向 View 添加标签

标签 titanium titanium-mobile

好吧,伙计们——我不得不承认,随着钛合金的开发继续困扰着我,我的挫败感越来越大。我所做的每一个改变,无论看起来多么无害,似乎都会以一种完全意想不到的方式破坏其他东西。

今天,我只是尝试向 View 添加标签,但它没有显示。

// UI Factory Include
var Inova = {};
Ti.include( '_ui.js' );

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

// Header
win.add( Inova.ui.createHeaderView() );

// body
var body = Ti.UI.createView({
    backgroundColor:'#00f', // Should see no blue
    backgroundImage: '/images/body.png',
    height: 350,
    layout: 'vertical',
});
var label = Ti.UI.createLabel({
    color: '#000',
    text: 'Show me the label...please?',
    textAlign: 'center',
});
body.add( label );

win.add( body );

我知道我必须错过一些极其愚蠢和基本的东西,但我认为我已经失去了看到显而易见的事情的所有能力。帮忙?

最佳答案

我认为您需要在标签中显式设置宽度/高度。您可以将其设置为 width: 'auto', height: 'auto' 但必须设置。

(奇怪的是,根据我的经验,Andriod 中情况并非如此)。

关于Titanium 向 View 添加标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7836210/

相关文章:

design-patterns - Titanium 中的自执行函数

android - 谷歌地图 v2 模块。 Android 应用程序未在 map View 中显示 map

android - Titanium:检查设备上是否安装了应用程序(android)

javascript - 如何在我的 iPhone 应用程序中缓存 Javascript 和 JSON 数据?

javascript - Titanium Javascript 运行时错误

titanium - 如何在 Titanium 中分离(拆分)字符串?

javascript - 在 Titanium 中分离平台特定代码的最佳方法

javascript - 使用 appcelerator titan 在 android 上进行多个预定的 android 通知

android - 您如何支持 Titanium 中不同平台的不同 View

Titanium 中的 Android DDMS 未启动内存堆