LoginSignup
7
7

Titanium Mobileの基本的な事柄

Last updated at Posted at 2013-11-10

特徴

  • JavaScriptでAndroid/iOSのネイティブアプリを作成できる
  • Android/iOSのアプリを同じコードで開発可能
  • 同じソースでもAndroid/iOSそれぞれ最適なUIになる

しくみ

  • JavaScriptで書かれたバイナリをTitanium エンジンが実行時に解釈して実行するしくみのよう

  • JavaScriptのコードはTitanium APIを呼び出して実装

  • JavaScriptエンジンは Titanium APIを解釈し、各プラットフォームのAPIを呼び出す

  • http://docs.appcelerator.com/titanium/latest/#!/guide/Titanium_Platform_Overview には、"Mobile applications built with the Titanium SDK are run against a standalone JavaScript engine which invokes native APIs." と ". The Titanium tools combine your JavaScript source code, a JavaScript interpreter, and your static assets into an application binary that will be installed to an emulator or mobile device." と書いてある。

  • applieの規約的にも問題がない模様 http://www.apple.com/pr/library/2010/09/09Statement-by-Apple-on-App-Store-Review-Guidelines.html => "In particular, we are relaxing all restrictions on the development tools used to create iOS apps, as long as the resulting apps do not download any code. This should give developers the flexibility they want, while preserving the security we need."

コード

環境

  • http://www.appcelerator.com/ からSDKをダウンロード(ユーザ登録が必要)
  • Titanium StudioというEclipseベースのIDEをダウンロードすることになる
  • Titanium Studioを通して、SDKやCLIツールをダウンロードする

Alloy

ひな形

// this sets the background color of the master UIView (when there are no windows/tab groups on it)
Titanium.UI.setBackgroundColor('#000');

// create tab group
var tabGroup = Titanium.UI.createTabGroup();


//
// create base UI tab and root window
//
var win1 = Titanium.UI.createWindow({  
    title:'Tab 1',
    backgroundColor:'#fff'
});
var tab1 = Titanium.UI.createTab({  
    icon:'KS_nav_views.png',
    title:'Tab 1',
    window:win1
});

var label1 = Titanium.UI.createLabel({
	color:'#999',
	text:'I am Window 1',
	font:{fontSize:20,fontFamily:'Helvetica Neue'},
	textAlign:'center',
	width:'auto'
});

win1.add(label1);

//
// create controls tab and root window
//
var win2 = Titanium.UI.createWindow({  
    title:'Tab 2',
    backgroundColor:'#fff'
});
var tab2 = Titanium.UI.createTab({  
    icon:'KS_nav_ui.png',
    title:'Tab 2',
    window:win2
});

var label2 = Titanium.UI.createLabel({
	color:'#999',
	text:'I am Window 2',
	font:{fontSize:20,fontFamily:'Helvetica Neue'},
	textAlign:'center',
	width:'auto'
});

win2.add(label2);



//
//  add tabs
//
tabGroup.addTab(tab1);  
tabGroup.addTab(tab2);  


// open tab group
tabGroup.open();

Titanium-sample.png

API

モジュール

モジュールの概要

モジュールのライセンス

  • ライセンスに関しては言及されてないが… Apacheライセンスで混ぜるな危険ではない+元と組み込む必要がないので、自由にライセンスつけていいのではないか。
  • https://github.com/laiso/titanium-hatenabookmark 見たいにMITライセンスとか別のライセンスで公開している
  • マーケットプレイスで有償のモジュールはコードが公開されているわけではないので(コード公開したら有償にならない)、モジュールは公開しなくてもいいのかも
7
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
7