Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/322.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/multithreading/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在Xamarin.Forms.iOS中获得访问html文件的正确路径?_C#_Xamarin_Path_Xamarin.ios_Xamarin.forms - Fatal编程技术网

C# 如何在Xamarin.Forms.iOS中获得访问html文件的正确路径?

C# 如何在Xamarin.Forms.iOS中获得访问html文件的正确路径?,c#,xamarin,path,xamarin.ios,xamarin.forms,C#,Xamarin,Path,Xamarin.ios,Xamarin.forms,我已经创建了一个html文件,我现在正试图访问它,但我遇到了一点麻烦。当我在iOS地图中有YTPlayerView iframe player.html文件时,代码当前看起来是这样的: const string HTMLTemplatePath = @"YTPlayerView-iframe-player.html"; string path = Path.Combine(NSBundle.MainBundle.BundlePath, HTMLTemplatePath); 当我尝试创建上面

我已经创建了一个html文件,我现在正试图访问它,但我遇到了一点麻烦。当我在iOS地图中有
YTPlayerView iframe player.html
文件时,代码当前看起来是这样的:

const string HTMLTemplatePath = @"YTPlayerView-iframe-player.html"; 

string path = Path.Combine(NSBundle.MainBundle.BundlePath, HTMLTemplatePath);
当我尝试创建上面的路径时,会出现以下错误消息导致崩溃:

找不到路径的一部分“/var/containers/Bundle/Application/252DA-6758-4650-88E0-F30‌​043043/myProject.iOS‌​.应用程序/播放器‌​查看iframe播放器.h‌​tml“

我需要如何调整才能使其正常工作?我是否需要将html文件移到其他位置(可能在共享(项目)文件夹中?)或需要调整HTMLTemplatePath字符串

这是html文件的外观:

<html>
<head>
<style>
 body { margin: 0; width:100%%; height:100%%; }
 html { width:100%%; height:100%%; }
</style>
</head>
<body>
<div id="player"></div>
<script src="https://www.youtube.com/iframe_api"></script>
<script>
var player;
YT.ready(function() {
  player = new YT.Player('player', %%jsontemp%%);
  window.location.href = 'ytplayer://onYouTubeIframeAPIReady';
});
function onReady(event) {
    window.location.href = 'ytplayer://onReady?data=' + event.data;
}
function onStateChange(event) {
    window.location.href = 'ytplayer://onStateChange?data=' + event.data;
}
function onPlaybackQualityChange(event) {
    window.location.href = 'ytplayer://onPlaybackQualityChange?data=' + event.data;
}
function onPlayerError(event) {
    window.location.href = 'ytplayer://onError?data=' + event.data;
}
</script>
</body>
</html>

正文{边距:0;宽度:100%%;高度:100%%;}
html{宽度:100%%;高度:100%%;}
var播放器;
YT.ready(函数(){
player=新的YT.player('player',%%jsontemp%%);
window.location.href=ytplayer://onYouTubeIframeAPIReady';
});
函数onReady(事件){
window.location.href=ytplayer://onReady?data=“+事件数据;
}
函数onStateChange(事件){
window.location.href=ytplayer://onStateChange?data=“+事件数据;
}
函数onPlaybackQualityChange(事件){
window.location.href=ytplayer://onPlaybackQualityChange?data=“+事件数据;
}
函数onplayerror(事件){
window.location.href=ytplayer://onError?data=“+事件数据;
}

该文件在项目中的位置?是否将其生成操作设置为内容?它现在位于我的iOS文件夹中。我在哪里可以找到“构建操作”?是否在“iOS构建”下?右键单击解决方案浏览器/pad中的文件。确定!我现在就把它设置为内容。让我们试试看!工作得很好,似乎:)我现在得到另一个错误,这是进步!谢谢