Iphone 相机,钛金属加速器
Posted
技术标签:
【中文标题】Iphone 相机,钛金属加速器【英文标题】:Iphone Camera, Titanium Appcelerator 【发布时间】:2012-06-12 14:31:35 【问题描述】:我正在使用 Titanium Appcelerator 创建一个 iPhone 应用程序。对于其中一个选项卡,我想包括一个相机。当我点击相机图像时,我希望应用:
打开相机拍照 询问用户是否想再拍一张照片 然后再打开摄像头就可以了 (循环) 将图像(本地保存)放入数组中 返回按钮!我似乎在任何地方都找不到相机功能。
【问题讨论】:
developer.appcelerator.com/questions/tag/camera 【参考方案1】:此链接提供了一个简短的示例,但建议查看厨房水槽演示应用程序,厨房水槽几乎包含所有示例。
http://developer.appcelerator.com/question/66021/api---camera
【讨论】:
【参考方案2】:var win = Titanium.UI.createWindow(
title:"Using the Camera and Video",
backgroundColor:"#FFFFFF"
);
var button = Titanium.UI.createButton(
title:"Use camera",
width:180,
height:48,
bottom: 12,
zIndex:2
);
button.addEventListener("click", function(e)
//Open the photo gallery
Titanium.Media.showCamera(
//function to call upon successful load of the gallery
success:function(e)
if(e.mediaType === Titanium.Media.MEDIA_TYPE_PHOTO)
//e.media represents the photo or video
var imageView = Titanium.UI.createImageView(
image:e.media,
width:320,
height:480,
top:12,
zIndex:1
);
win.add(imageView);
else if(e.mediaType === Titanium.Media.MEDIA_TYPE_VIDEO)
var w = Titanium.UI.createWindow(
title:"New Video",
backgroundColor:"#000000"
);
var videoPlayer = Titanium.Media.createVideoPlayer(
media:e.media,
backgroundColor:"#FFFFFF",
//movieControlMode:Titanium.Media.VIDEO_CONTROL_DEFAULT,
/*other values
* Titanium.Media.VIDEO_CONTROL_EMBEDDED
* Titanium.Media.VIDEO_CONTROL_FULLSCREEN
* Titanium.Media.VIDEO_CONTROL_HIDDEN
* Titanium.Media.VIDEO_CONTROL_NONE
*/
//movieControlStyle:Titanium.Media.VIDEO_CONTROL_FULLSCREEN,
//scalingMode:Titanium.Media.VIDEO_SCALING_ASPECT_FIT
/*other values
* Titanium.Media.VIDEO_SCALING_ASPECT_FILL
* Titanium.Media.VIDEO_SCALING_MODE_FILL
* Titanium.Media.VIDEO_SCALING_NONE
*/
);
w.add(videoPlayer);
videoPlayer.addEventListener("complete", function(e)
w.remove(videoPlayer);
videoPlayer = null;
w.close();
);
w.open(modal:true);
,
error:function(e)
alert("There was an error");
,
cancel:function(e)
alert("The event was cancelled");
,
//Allow editing of media before success
allowEditing:true,
saveToPhotoGallery:true,
//Media types to allow
mediaTypes:[Titanium.Media.MEDIA_TYPE_PHOTO,Titanium.Media.MEDIA_TYPE_VIDEO],
//The other is Titanium.Media.MEDIA_TYPE_VIDEO,
//If recording video, you can set the quality to record at
videoQuality:Titanium.Media.QUALITY_HIGH
/*other possible values for this property are
* Titanium.Media.QUALITY_MEDIUM
* Titanium.Media.QUALITY_LOW
*/
);
);
Titanium.App.addEventListener('camera_button', function()
Titanium.Media.takePicture();
);
win.add(button);
win.open();
【讨论】:
以上是关于Iphone 相机,钛金属加速器的主要内容,如果未能解决你的问题,请参考以下文章