Post

Replies

Boosts

Views

Activity

How not to let Home button quit your tvOS app in SwiftUI
Hi! In UIKit we can use GCEventViewController to intercept the game controllers from propagating Home button presses to the responders (and have them quit our app) by setting controllerUserInteractionEnabled = false SwiftUI Apps do not use ViewControllers, so, except for resurrecting one to embed the whole app in it, we can't use the above solution to avoid the player leaving out game / app by accident by pressing the wrong button (not can we use buttonB) Does anyone know a solution to this conundrum? Did Apple already implement a new way to intercept high-level events so we can deal with them internally? Thanks!
0
0
812
Mar ’21
Transparent NSHostingController in SceneKit
I'm doing an experiment integrating SwiftUI views as Materials for a SceneKit scene SCNPanel node. It is working perfectly in iOS using UIHostingController with the following code: Swift func createInfoPanel() { let panel = SCNPlane(width: 6.0, height: 6.0) let panelNode = SCNNode(geometry: panel) let infoPanelHost = SCNHostingController(rootView: helloWorld) infoPanelHost.view.isOpaque = false infoPanelHost.view.backgroundColor = SCNColor.clear infoPanelHost.view.frame = CGRect(x: 0, y: 0, width: 256, height: 256) panel.materials.first?.diffuse.contents = infoPanelHost.view panel.materials.first?.emission.contents = infoPanelHost.view panel.materials.first?.emission.intensity = 3.0 [... BillBoardConstraint etc here ...] addNodeToScene(panelNode) } Yet, when I tried to apply the same to macOS, I don't seem to be able to make the view created by NSHostingController transparent. Invoking infoPanelHost.view.isOpaque = false returns an error, saying isOpaque is read-only and can't be set. I tried subclassing NSHostingController and overriding viewWillAppear to try and make the view transparent / non-opaque, to no avail. Swift override func viewWillAppear() { super.viewWillAppear() self.view.wantsLayer = true self.view.layer?.backgroundColor = NSColor.clear.cgColor self.view.layer?.isOpaque = false self.view.opaqueAncestor?.layer?.backgroundColor = NSColor.clear.cgColor self.view.opaqueAncestor?.layer?.isOpaque = false self.view.opaqueAncestor?.alphaValue = 0.0 self.view.alphaValue = 0.0 self.view.window?.isOpaque = false self.view.window?.backgroundColor = NSColor.clear     } Tried setting everything I could think of to non-opaque as you can see, and still, the panels are opaque, show no info, and obscure the 3D entity they should overlay... Can someone please advise?
2
0
1.3k
Mar ’21
Using Network.framework TCP/TLS on iOS client. What should I use on Linux server?
Hi, everyone,We're developing a client-server App under contract, the client to run on iOS 13 and the server on RedHat Linux (cloud).Our App uses TCP/TLS streaming for real-time sync using a single JSON-encoded update object transfered between server and client in a very action game-like manner.We've recently finished the network / communication implementation using Apple's new Network.framework and it is working like a charm: fast, reliable, secure.The only problem now is: there doesn't seem to be a Network.famework implementation for Swift on Linux! Is that correct, or we just did not find it?If indeed there is none, what would the Linux / SwiftNIO equivalent be for streaming TCP/TLS messages so we can keep the client code we already developed (and hope for an official implementation for Linux in the future)?Looking back, we should have checked first, we just were to excited with NWframework 😉Thanks! Tarq
4
0
1.9k
Jan ’20