我正在尝试使用 WebView 加载 YouTube 视频。视频播放效果很好,完全符合我的要求,但调试器不断发出警告(见结尾)。此警告重复约 20 次。
我试图隔离问题并创建一个没有任何约束的新 ViewController,它仍然显示与约束相关的警告。
我尝试使用 .translatesAutoresizingMask 和 .scalesToFitPage 但它们似乎没有什么区别。
这是我用来嵌入视频的代码:
// webView from an IBOutlet in an empty ViewController without any constraints
func playVideo(){
var staticUrlString = "https://www.youtube.com/watch?v=jNQXAC9IVRw"
var youtubeVideoId = NSString(string: staticUrlString)
var rng: NSRange = youtubeVideoId.rangeOfString("&feature=")
if(rng.length>0){
youtubeVideoId = youtubeVideoId.stringByReplacingCharactersInRange(NSMakeRange(rng.location, youtubeVideoId.length-rng.location), withString: "")
}
youtubeVideoId = youtubeVideoId.stringByReplacingOccurrencesOfString("http://www.youtube.com/watch?v=", withString: "")
youtubeVideoId = youtubeVideoId.stringByReplacingOccurrencesOfString("https://www.youtube.com/watch?v=", withString: "")
var youTubeVideoHTML: NSString = NSString(format: "<!DOCTYPE html><html><head><style>body{margin:0px 0px 0px 0px; background:#1111}</style></head> <body> <div id=\"player\"></div> <script> var tag = document.createElement('script'); tag.src = \"http://www.youtube.com/player_api\"; var firstScriptTag = document.getElementsByTagName('script')[0]; firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); var player; function onYouTubePlayerAPIReady() { player = new YT.Player('player', { width:'%0.0f', height:'%0.0f', videoId:'%@', events: { 'onReady': onPlayerReady, 'onStateChange': onPlayerStateChange } });} function onPlayerReady(event) { event.target.playVideo(); } function onPlayerStateChange(event) {if(event.data === 0) { event.target.destroy(); }} </script> </body> </html>",0.0, 0.0,youtubeVideoId)
//webView.translatesAutoresizingMaskIntoConstraints()
//webView.scalesPageToFit = false
webView.mediaPlaybackRequiresUserAction = false
webView.opaque = false
webView.loadHTMLString(youTubeVideoHTML, baseURL: NSURL(string: NSString(format: "http://www.youtube.com/watch?v=%@", youtubeVideoId)))
println("play")
}
这是警告之一:
Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)
(
"<NSLayoutConstraint:0x7cb37910 UIImageView:0x7cb36fb0.centerX == AVUnsupportedContentIndicatorView:0x7cb36cf0.centerX>",
"<NSLayoutConstraint:0x7cb37d70 H:[UIImageView:0x7cb36fb0]-(>=10)-| (Names: '|':AVUnsupportedContentIndicatorView:0x7cb36cf0 )>",
"<NSLayoutConstraint:0x7cb4f430 H:|-(0)-[AVUnsupportedContentIndicatorView:0x7cb36cf0] (Names: '|':UIView:0x7cb36b20 )>",
"<NSLayoutConstraint:0x7cb4f460 H:[AVUnsupportedContentIndicatorView:0x7cb36cf0]-(0)-| (Names: '|':UIView:0x7cb36b20 )>",
"<NSLayoutConstraint:0x7cb4f310 H:|-(0)-[UIView:0x7cb36b20] (Names: '|':AVPlayerView:0x7cb36860 )>",
"<NSLayoutConstraint:0x7cb4f360 H:[UIView:0x7cb36b20]-(0)-| (Names: '|':AVPlayerView:0x7cb36860 )>",
"<NSLayoutConstraint:0x7cb5ef40 'UIView-Encapsulated-Layout-Width' H:[AVPlayerView:0x7cb36860(1)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x7d342240 UIView:0x7d229b90.centerX == AVExternalPlaybackIndicatorView:0x7d22a150.centerX>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
最佳答案
您收到警告的约束似乎与您直接创建的 View 无关——它们与 Apple 的内部 View 结构有关。
这(很可能)是一个错误。您应该在此处提交报告:https://bugreport.apple.com .
关于ios - 尝试从 WebView 加载 YouTube 视频时出现约束警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26632201/
我正在用Ruby编写一个简单的程序来检查域列表是否被占用。基本上它循环遍历列表,并使用以下函数进行检查。require'rubygems'require'whois'defcheck_domain(domain)c=Whois::Client.newc.query("google.com").available?end程序不断出错(即使我在google.com中进行硬编码),并打印以下消息。鉴于该程序非常简单,我已经没有什么想法了-有什么建议吗?/Library/Ruby/Gems/1.8/gems/whois-2.0.2/lib/whois/server/adapters/base.
我想为Heroku构建一个Rails3应用程序。他们使用Postgres作为他们的数据库,所以我通过MacPorts安装了postgres9.0。现在我需要一个postgresgem并且共识是出于性能原因你想要pggem。但是我对我得到的错误感到非常困惑当我尝试在rvm下通过geminstall安装pg时。我已经非常明确地指定了所有postgres目录的位置可以找到但仍然无法完成安装:$envARCHFLAGS='-archx86_64'geminstallpg--\--with-pg-config=/opt/local/var/db/postgresql90/defaultdb/po
我试图使用yard记录一些Ruby代码,尽管我所做的正是所描述的here或here#@param[Integer]thenumberoftrials(>=0)#@param[Float]successprobabilityineachtrialdefinitialize(n,p)#initialize...end虽然我仍然得到这个奇怪的错误@paramtaghasunknownparametername:the@paramtaghasunknownparametername:success然后生成的html看起来很奇怪。我称yard为:$yarddoc-mmarkdown我做错了什么?
鉴于我有以下迁移:Sequel.migrationdoupdoalter_table:usersdoadd_column:is_admin,:default=>falseend#SequelrunsaDESCRIBEtablestatement,whenthemodelisloaded.#Atthispoint,itdoesnotknowthatusershaveais_adminflag.#Soitfails.@user=User.find(:email=>"admin@fancy-startup.example")@user.is_admin=true@user.save!ende
我正在使用active_admin,我在Rails3应用程序的应用程序中有一个目录管理,其中包含模型和页面的声明。时不时地我也有一个类,当那个类有一个常量时,就像这样:classFooBAR="bar"end然后,我在每个必须在我的Rails应用程序中重新加载一些代码的请求中收到此警告:/Users/pupeno/helloworld/app/admin/billing.rb:12:warning:alreadyinitializedconstantBAR知道发生了什么以及如何避免这些警告吗? 最佳答案 在纯Ruby中:classA
最近,当我启动我的Rails服务器时,我收到了一长串警告。虽然它不影响我的应用程序,但我想知道如何解决这些警告。我的估计是imagemagick以某种方式被调用了两次?当我在警告前后检查我的git日志时。我想知道如何解决这个问题。-bcrypt-ruby(3.1.2)-better_errors(1.0.1)+bcrypt(3.1.7)+bcrypt-ruby(3.1.5)-bcrypt(>=3.1.3)+better_errors(1.1.0)bcrypt和imagemagick有关系吗?/Users/rbchris/.rbenv/versions/2.0.0-p247/lib/ru
我收到这个错误:RuntimeError(自动加载常量Apps时检测到循环依赖当我使用多线程时。下面是我的代码。为什么会这样?我尝试多线程的原因是因为我正在编写一个HTML抓取应用程序。对Nokogiri::HTML(open())的调用是一个同步阻塞调用,需要1秒才能返回,我有100,000多个页面要访问,所以我试图运行多个线程来解决这个问题。有更好的方法吗?classToolsController0)app.website=array.join(',')putsapp.websiteelseapp.website="NONE"endapp.saveapps=Apps.order("
我正在尝试编写一个将文件上传到AWS并公开该文件的Ruby脚本。我做了以下事情:s3=Aws::S3::Resource.new(credentials:Aws::Credentials.new(KEY,SECRET),region:'us-west-2')obj=s3.bucket('stg-db').object('key')obj.upload_file(filename)这似乎工作正常,除了该文件不是公开可用的,而且我无法获得它的公共(public)URL。但是当我登录到S3时,我可以正常查看我的文件。为了使其公开可用,我将最后一行更改为obj.upload_file(file
这里有一个很好的答案解释了如何在Ruby中下载文件而不将其加载到内存中:https://stackoverflow.com/a/29743394/4852737require'open-uri'download=open('http://example.com/image.png')IO.copy_stream(download,'~/image.png')我如何验证下载文件的IO.copy_stream调用是否真的成功——这意味着下载的文件与我打算下载的文件完全相同,而不是下载一半的损坏文件?documentation说IO.copy_stream返回它复制的字节数,但是当我还没有下
我是Google云的新手,我正在尝试对其进行首次部署。我的第一个部署是RubyonRails项目。我基本上是在关注thisguideinthegoogleclouddocumentation.唯一的区别是我使用的是我自己的项目,而不是他们提供的“helloworld”项目。这是我的app.yaml文件runtime:customvm:trueentrypoint:bundleexecrackup-p8080-Eproductionconfig.ruresources:cpu:0.5memory_gb:1.3disk_size_gb:10当我转到我的项目目录并运行gcloudprevie