Tag: swift3

捕获金属MTKView作为电影实时?

什么是从MTKView捕获帧的最有效的方法? 如果可能的话,我想实时保存帧中的.mov文件。 是否有可能渲染成一个AVPlayer框架或东西? 目前正在使用此代码(基于@warrenm PerformanceShaders 项目 )进行绘制: func draw(in view: MTKView) { _ = inflightSemaphore.wait(timeout: DispatchTime.distantFuture) updateBuffers() let commandBuffer = commandQueue.makeCommandBuffer() commandBuffer.addCompletedHandler{ [weak self] commandBuffer in if let strongSelf = self { strongSelf.inflightSemaphore.signal() } } // Dispatch the current kernel to perform the selected image filter selectedKernel.encode(commandBuffer: commandBuffer, sourceTexture: kernelSourceTexture!, destinationTexture: kernelDestTexture!) if let renderPassDescriptor […]

在Swift中使用select器3

我在Swift 3中编写我的iOS应用程序。 我有一个UIViewController扩展,我必须检查控制器实例是否响应一个方法。 下面是我尝试的代码。 extension UIViewController { func myMethod() { if self.responds(to: #selector(someMethod)) { } }} 这里的responds(to:)方法会引发编译时错误 使用未parsing的标识符“someMethod”。 我在另一篇文章中读到,我们必须在select器参数中使用self ,但即使这样也会引发一些错误。

如何将访问令牌传递给Alamofire?

我正在尝试在Alamofire传递访问令牌,但在Web上的各种方法中感到困惑。 以下是我们需要使用的方法。 let todosEndpoint: String = "https:url……." let headers = [ "Authorization": "Bearer \(token!)", "Content-Type": "application/X-Access-Token" ] let Auth_header = [ "Authorization" : tokenString! ] Alamofire.request(todosEndpoint, method: .get, parameters: nil, encoding: JSONEncoding.default, headers: Auth_header) .responseJSON { response in print("response.request \(response.request)") // original URL request print("response.response \(response.response)") // HTTP URL response print("response.data \(response.data)") // server data […]

在iOS的应用程序购买testing

我正在使用Xcode 8.0,Swift 3.0和在iPad上购买应用程序进行testing。 我想使用沙箱用户在应用程序购买testing。 设备的设置中没有添加帐户 问题是我没有得到产品列表响应产品请求代码。 请看我的代码: let PRODUCT_ID_MY_PRODUCT = "com.company.ProjectName.MyProduct" // The ProducID in this code and ProducID on iTunes are the SAME. ✔️ override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) if productID == nil { productID = PRODUCT_ID_MY_PRODUCT } SKPaymentQueue.default().add(self) } override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) startPurchases() } func startPurchases() { […]

如何将Unity整合到Swift 3 iOS项目中

我只是想知道在现有的Swift 3 iOS项目中实现Unity项目最好的策略是什么。 到目前为止,我只在Objective-C中发现了示例代码。 有没有stream行的框架或包装?

如何在消息扩展中发送MSMessage?

我想实现一个imessage应用程序,但是对于消息框架和新的iMessage应用程序来说,新的东西没有太多的资源。 所以我正在关注WWDCvideo,并使用提供示例应用程序的 Apples来指导。 我有三个视图, MessageViewController处理几乎所有的function,然后CreateViewController和DetailsViewController 。 我只是试图从CreateViewController创build一个MSMessage ,并显示在DetailsViewController ..然后添加到数据。 但是,当我尝试创build数据时遇到了崩溃。 @IBAction func createAction(_ sender: AnyObject) { //present full screen for create list self.delegate?.createViewControllerDidSelectAdd(self as! CreateViewControllerDelegate) } 我试图传递的数据types是结构体中的字典: struct data { var title: String! var date: Date! var dictionary = ["title" : String(), "Array1" : [String](), "Array2" : [String]() ] as [String : Any] } 所以这里是如何build立的。 […]

简单的隧道构build失败 – NEAppProxyErrorDomain

我下载了SimpleTunnel的最新版本。 https://developer.apple.com/library/content/samplecode/SimpleTunnel/Introduction/Intro.html#//apple_ref/doc/uid/TP40016140-Intro-DontLinkElementID_2 我有Xcode 8.1。 当我尝试构build该项目时,我在ClientAppProxyConnection文件中收到2次错误“使用未声明types'NEAppProxyErrorDomain'”,在这些行中: func handleErrorCondition(_ flowError:NEAppProxyErrorDomain?= nil,notifyServer:Bool = true){func closeConnection(_ direction:TunnelConnectionCloseDirection,flowError:NEAppProxyErrorDomain?){ 我试图清理这个项目并重build它们几次,然后我删除了整个项目并再次下载等。 我能做什么? 问候,

Facebooklogin不能返回到应用程序迁移到Swift 3

我创build了一个示例应用程序,用户使用Facebookloginbuttonlogin。 login后,我会在login屏幕上显示用户名和电子邮件地址。 它与Swift 2.3一起工作。 一旦我迁移到Swift 3,它就停止工作。 第一步:使用Facebookloginbuttonlogin 第二步:允许电子邮件和个人资料的权限 第三步:在这里它应该回到屏幕1,但它不。 附加日志当我点击“确定”button时获得。 更新1:应用程序在iOS 9.3上运行良好。 该问题仅在iOS 10设备上发生。 2016-06-19 08:30:09.300070 MyApp[13942:1214112] [] nw_endpoint_handler_start [4 graph.facebook.com:443 initial path (null)] 2016-06-19 08:30:09.300484 MyApp[13942:1214112] [] nw_connection_endpoint_report [4 graph.facebook.com:443 initial path (null)] reported event path:start 2016-06-19 08:30:09.301255 MyApp[13942:1214112] [] nw_connection_endpoint_report [4 graph.facebook.com:443 waiting path (satisfied)] reported event path:satisfied 2016-06-19 08:30:09.302664 MyApp[13942:1214112] [] nw_connection_endpoint_report […]

无法重写在另一个模块swift中的类扩展中声明的打开方法

我有一个类扩展声明在另一个模块(使用豆荚)这样的。 public extension UIView { open func doStuff() {…} } 当我尝试在我的当前项目模块中的子类中重写此方法 class ConcreteView : UIView { override open func doStuff() {…} } 我收到一个错误: 在其定义模块之外重写非开放实例方法 尽pipe方法实际上标记为打开 作为一种解决方法,我声明了另一个类在同一个模块中扩展声明和覆盖所需的方法 public class CustomView: UIView { override open func doStuff() {…} } 并将该类设置为主模块中的我的类的超类 class ConcreteView : CustomView 所以只有在这之后我才能够重写这个方法。 它看起来像swift中的一个bug,但也许我忽略了为什么它以这种方式工作的一些理解?

Swift 3 – 调整字体大小以适应宽度,多行

我有一个UILabel,它被设置为42.0pt字体,并且标签的宽度是基于除了标签本身之外的因素(也就是标签的左侧和右侧的东西决定标签的宽度)使用自动约束来设置的。 我想自动调整字体大小,以适应标签的宽度,但也可以打破两行。 与此类似: 我知道你可以调整字体大小来适应标签的宽度,但只有当行数设置为1时。 我将如何做到这一点?