简体   繁体   English

无法从Appcelerator中的WebView打开相机

[英]Not able to open the camera from the WebView in appcelerator

Currently i am working on load a url inside a webview, by using that same url in browser, it's able to access the camera "by showing a alert to access camera", but when i using the same url inside a webview in an application by appcelerator not able to access the camera . 目前,我正在通过在浏览器中使用相同的URL来加载Web视图中的URL,它能够“通过显示访问摄像头的警报”来访问摄像机,但是当我在应用程序中的Web视图中使用相同的URL时, Appcelerator无法访问摄像机。 If guide me to solve this . 如果指导我解决这个问题。

Thanks in advance . 提前致谢 。

You can fire Ti event from webview and inside the event listener access the camera 您可以从webview触发Ti事件,并且可以在事件监听器中访问摄像头

Ex :- 例如:

webview file 网络视图文件

<html>
    <head>
        <script>
            Ti.App.addEventListener("app:fromTitanium", function(e) {
                alert(e.message);
            });
        </script>
    </head>
    <body>
        <button onclick="Ti.App.fireEvent('app:fromWebView', { message: 'event fired from WebView, handled in Titanium' });">fromWebView</button>
    </body>
</html>

Js file js文件

var win = Ti.UI.createWindow();
var webview = Ti.UI.createWebView({
    url: 'logging.html'
});
var button = Ti.UI.createButton({
    title: 'fromTitanium',
    height: '50dp',
    width: '130dp'
});
button.addEventListener('click', function(e) {
    Ti.App.fireEvent('app:fromTitanium', { message: 'event fired from Titanium, handled in WebView' });
});
Ti.App.addEventListener('app:fromWebView', function(e) {
    alert(e.message);
});
win.add(webview);
win.add(button);
win.open();

More details http://docs.appcelerator.com/platform/latest/#!/guide/Communication_Between_WebViews_and_Titanium 更多详细信息http://docs.appcelerator.com/platform/latest/#!/guide/Communication_Between_WebViews_and_Titanium

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM