jjzjj

playgrounds

全部标签

swift - 为什么我不能在 Playground 中使用 AVURLAsset 从媒体文件中提取数据?

在我的Playground上:importCocoaimportFoundationimportAVFoundationvarpath2="/Users/me/Movies/bukesiyi.mp4"varvideo2=NSURL(fileURLWithPath:path2,isDirectory:false)//itshows:file:///Users/me/Movies/bukesiyi.mp4video2.checkResourceIsReachableAndReturnError(nil)//it'struevarasset=AVURLAsset(URL:video2)//i

ios - 如何在 Swift playground 中停止帧的大小变为 1024x768

UIViewController中主视图的frame变为1024x768一开始问题不明显,后来做布局的时候就麻烦了。如何确保框架与我使用.preferredContentSize设置的大小保持相同?importUIKitimportPlaygroundSupportclassMyViewController:UIViewController{overrideopenfuncviewDidLoad(){super.viewDidLoad()self.view.backgroundColor=UIColor.whiteself.view.frame//Whenrunplaygroundsh

Swift playground 显示错误的语句执行次数(forEach on array)

我一直在探索仿函数,但在理解forEach仿函数在幕后的作用时遇到了一些困难。例如,当我将其输入Playground时:letarray=[1]//[1]array.forEach{$0.value}//(3times)array.forEach{_inprint("hello")}//(2times)当我展开(3times)或(2times)时,它只显示()其中一个,为什么对1个元素的数组执行多次,为什么两次forEach计算的执行次数不同? 最佳答案 这是一个相当困惑的情况。让我们首先考虑第二个forEach:array.for

ios - Swift playgrounds ios 10 文字转语音命令代码

我在iOSiPad上使用swiftplaygrounds创建文本转语音命令。下面是代码。importAVFoundationletsynthesizer=AVSpeechSynthesizer()letutterance=AVSpeechUtterance(string:"SayHello")utterance.rate=1synthesizer.speak(utterance:AVSpeechUtterance)//当我点击“运行我的代码”时。我收到错误消息“尝试评估编辑器占位符”我不知道这个错误是什么意思。希望有人能提供帮助。谢谢你。 最佳答案

swift - Playgrounds "Collect, Toggle, Repeat"包含 10 个或更少的基本命令?

iPadPlaygroundsapp,很早的挑战:你正在学习编程,你对变量、循环等一无所知。你唯一知道的关键字是func。游戏建议您第一次构建自己的功能。基本上,您只会使用屏幕上显示的内容:collectGem()、moveForward()、name()、toggleSwitch(),turnLeft(),turnRight()。你不会意外摔倒(所以额外的Action是可以接受的),目标是收集4颗gem并切换4个开关。我的第一次尝试是:谜题解决了,但告诉我:butyouused11commands!Trydefiningyourownfunction[...]Youwon'tneed

swift - 为什么 Swift playground 显示错误的执行次数?

我正在使用完成处理程序来汇总数字。我不明白的是,如果我将代码分成两行,执行次数将从6次变为7次!!为什么?funcsummer(from:Int,to:Int,handler:(Int)->(Int))->Int{varsum=0foriinfrom...to{sum+=handler(i)}returnsum}summer(1,to:6){//Shows'21'return$0}//shows'(6times)'//Samecode,butin1linesummer(1,to:6){return$0}//shows'(7times)'图片 最佳答案

swift - 如何在 Playgrounds 中设置 ViewController?

在swiftplaygrounds中,如何设置和使用ViewController?我以前用UIView做过,但是当方向不同时UI会被切断,所以我想尝试使用viewcontroller。我有letview=UIViewController()但在那之后我如何设置它来添加背景和东西? 最佳答案 要在Swiftplayground中创建ViewController,您需要以下代码:importUIKitimportPlaygroundSupportclassViewController:UIViewController{overridef

swift - `Calendar` API 崩溃 Swift Playground

简单的Playground:importFoundation//letc1=Calendar.sharedletc2=Calendar(identifier:.gregorian)我在两者之间切换,在运行playground时都给出相同的错误:error:Executionwasinterrupted,reason:EXC_BAD_ACCESS(code=EXC_I386_GPFLT).我正在运行Xcode9beta2 最佳答案 它在Xcode9.0GM中工作。正如Hamish所说,测试版软件存在缺陷。:)

ios - 如何将桥接头添加到 Xcode Playground?

是否可以使用Bridging-Header文件将ObjectiveC头文件包含到XcodePlayground? 最佳答案 我不这么认为。无法使用import让Playground识别框架,即使此框架是正确配置了Bridging-Header的项目的一部分。 关于ios-如何将桥接头添加到XcodePlayground?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/296965

ios - Playground 执行失败 : error: Couldn't lookup symbols

我正在使用Xcode7.3。我已经将Playground和Frameworks放在同一个工作区中并构建了框架。我仍然收到此错误Playgroundexecutionfailed:error:Couldn'tlookupsymbols:_RestofireVersionNumber如何解决? 最佳答案 如果您的库有.podspec,您可以使用cocoapods-playgrounds生成一个应该可以工作的Playground。$geminstallcocoapods-playgrounds$podplaygroundsRestofir