Created
August 21, 2012 07:01
-
-
Save setou/3412908 to your computer and use it in GitHub Desktop.
Titanium Mobileで作ったアプリを横向きに対応させたはずが、何だかとってもコレジャナイ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Titanium Mobile のView配置を横向きに対応させる(コレジャナイ!ソースコード) | |
* tiapp.xmlに以下を追加してください。※追加後はProjectのCleanを忘れずに。 | |
* <iphone> | |
* <orientations device="iphone"> | |
* <orientation>Ti.UI.PORTRAIT</orientation> | |
* <orientation>Ti.UI.LANDSCAPE_LEFT</orientation> | |
* <orientation>Ti.UI.LANDSCAPE_RIGHT</orientation> | |
* </orientations> | |
* </iphone> | |
*/ | |
if (Ti.version < 2.0 ) { | |
alert('Sorry - this application requires Titanium Mobile SDK 2.0 or later'); | |
} | |
var win = Ti.UI.createWindow(); | |
var topLeftView = Ti.UI.createView({ | |
top : (Ti.Platform.displayCaps.platformHeight/2)*0, | |
left : (Ti.Platform.displayCaps.platformWidth/3)*0, | |
height : Ti.Platform.displayCaps.platformHeight/2, | |
width : Ti.Platform.displayCaps.platformWidth/3, | |
backgroundColor : 'blue', | |
}); | |
win.add(topLeftView); | |
var topCenterView = Ti.UI.createView({ | |
top : (Ti.Platform.displayCaps.platformHeight/2)*0, | |
left : (Ti.Platform.displayCaps.platformWidth/3)*1, | |
height : Ti.Platform.displayCaps.platformHeight/2, | |
width : Ti.Platform.displayCaps.platformWidth/3, | |
backgroundColor : 'yellow', | |
}); | |
win.add(topCenterView); | |
var topRightView = Ti.UI.createView({ | |
top : (Ti.Platform.displayCaps.platformHeight/2)*0, | |
left : (Ti.Platform.displayCaps.platformWidth/3)*2, | |
height : Ti.Platform.displayCaps.platformHeight/2, | |
width : Ti.Platform.displayCaps.platformWidth/3, | |
backgroundColor : 'red', | |
}); | |
win.add(topRightView); | |
var bottomLeftView = Ti.UI.createView({ | |
top : Ti.Platform.displayCaps.platformHeight/2, | |
left : (Ti.Platform.displayCaps.platformWidth/3)*0, | |
height : Ti.Platform.displayCaps.platformHeight/2, | |
width : Ti.Platform.displayCaps.platformWidth/3, | |
backgroundColor : 'navy', | |
}); | |
win.add(bottomLeftView); | |
var bottomCenterView = Ti.UI.createView({ | |
top : Ti.Platform.displayCaps.platformHeight/2, | |
left : (Ti.Platform.displayCaps.platformWidth/3)*1, | |
height : Ti.Platform.displayCaps.platformHeight/2, | |
width : Ti.Platform.displayCaps.platformWidth/3, | |
backgroundColor : 'orange', | |
}); | |
win.add(bottomCenterView); | |
var bottomRightView = Ti.UI.createView({ | |
top : Ti.Platform.displayCaps.platformHeight/2, | |
left : (Ti.Platform.displayCaps.platformWidth/3)*2, | |
height : Ti.Platform.displayCaps.platformHeight/2, | |
width : Ti.Platform.displayCaps.platformWidth/3, | |
backgroundColor : 'pink', | |
}); | |
win.add(bottomRightView); | |
win.open(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment