Posts

Post marked as solved
1 Replies
702 Views
I am not able drag a reference object from a Storyboard screen to code in the Assistant. The expected blue line appears as the screenshot shows, but no code is created in the Assistant. This reference object is not in the Launch Screen. When the the screen this object is in is highlighted, the correct file opens in the Assistant. Dragging this object from the "Content View" folder also does not work, even though the blue line also appears. I was recently able to do this. Something changed. What might have changed?
Posted
by spflanze.
Last updated
.
Post not yet marked as solved
0 Replies
443 Views
The goal is to have the background, and foreground, colors show the current state of a UIButton on a storyboard file. The attempt to do that is done with this code: var toggleLight: Bool = false @IBAction func toggleLight(_ sender: UIButton) { if( toggleLight ){ toggleLight = false sender.baseBackgroundColor = UIColor.black sender.baseForegroundColor = UIColor.white }else{ toggleLight = true sender.baseBackgroundColor = UIColor.white sender.baseForegroundColor = UIColor.black } tableView.reloadData() } I get these errors: Value of type 'UIButton' has no member 'baseBackgroundColor' Value of type 'UIButton' has no member 'baseForegroundColor' I do not understand this because in file "UIKit.UIButton" I see: extension UIButton { ... public var baseForegroundColor: UIColor? public var baseBackgroundColor: UIColor? ... } What has gone wrong there?
Posted
by spflanze.
Last updated
.
Post not yet marked as solved
0 Replies
545 Views
Here is a code snippet by which I attempted to set a neutral white balance: func prepare(completionHandler: @escaping (Error?) -> Void) { func createCaptureSession() { self.captureSession = AVCaptureSession() } func configureCaptureDevices() throws { let session = AVCaptureDevice.DiscoverySession(deviceTypes: [.builtInWideAngleCamera], mediaType: AVMediaType.video, position: .back) let cameras = (session.devices.compactMap { $0 }) if cameras.isEmpty { throw CameraControllerError.noCamerasAvailable } for camera in cameras { try camera.lockForConfiguration() camera.setWhiteBalanceModeLocked( with whiteBalanceGains: AVCaptureDevice.WhiteBalanceGains( redGain: 1.0, greenGain: 1.0, blueGain: 1.0), completionHandler handler: ((CMTime) -> Void)? = nil ) // Errors: Extra arguments at positions #2, #3 in call, Cannot find 'with' in scope camera.whiteBalanceMode = .locked camera.unlockForConfiguration() }catch{ // To Do: Error handling here } } My call to "AVCaptureDevice.WhiteBalanceGains()" gets errors. What is the correct way to do this?
Posted
by spflanze.
Last updated
.
Post marked as solved
1 Replies
547 Views
I used the Interface Builder to place a Switch object in a view. I ctrl dragged it into the Assistant to make its handler a method of the class the view's is in, which is itself a subclass of "UITableViewController". A dialog box appear into which I entered the function name, and select the the option to have the sender as an argument. The result is function of the form: @IBAction func switchStateChange(_ sender: UISwitch) { } Now I need to query this Switch's On/Off state from elsewhere in the program, and if necessary change its state. It is not a good solution to save the sender parameter to a global variable because then it would require the user to change this switch's state before that global variable is set. What is needed is to identify, and lookup, this switch object to access it from anywhere in the application. How is this done?
Posted
by spflanze.
Last updated
.
Post not yet marked as solved
0 Replies
297 Views
The Storyboard Interface Builder has a Switch object that toggles between On, and Off, states. While in the On state it looks normal. While in the Off state it is grayed out. I have a use for this object for the user to toggle between two options which are other than On, and Off. For my intended use its Off state gray out is undesirable. Is there way to prevent this switch graying out in its Off state?
Posted
by spflanze.
Last updated
.
Post not yet marked as solved
2 Replies
608 Views
The need is to take pictures with Swift code settable parameters such as F-Stop, exposure time, and zoom level, in an iPhone 14 Pro. What AVCam methods control these? If there are none, are there other ways to do this? The option to have the torch constantly light on, or off, is also needed. Flash will not be used.
Posted
by spflanze.
Last updated
.
Post not yet marked as solved
0 Replies
361 Views
I have seen how to connect a button in a storyboard view to code that does its action by dragging that button into the assistant editor. Now I need to do the opposite. There is a button in the storyboard view that is already connected to code. How can that existing already connected code be quickly looked up for a button?
Posted
by spflanze.
Last updated
.
Post marked as solved
9 Replies
762 Views
In TicTacToe example there is in the override method "PasscodeViewController.viewDidLoad()" this snippet of code: if let browseResult = browseResult, case let NWEndpoint.service(name: name, type: _, domain: _, interface: _) = browseResult.endpoint { title = "Join \(name)" } What confuses me: The use of the "case" keyword without a switch statement. The "case" keyword does not have a constant to compare with to decide if will branch here. And what of the method call to NWEndpoint.service() being set equal to something? Is this actually defining what the service method will do when the system calls it?
Posted
by spflanze.
Last updated
.
Post marked as solved
1 Replies
265 Views
There is the iPhone's name that can be looked up, and altered, by navigating to: Settings > General > About > Name How can a Swift application access this name? It is only the device name I seek, not the username.
Posted
by spflanze.
Last updated
.
Post marked as solved
1 Replies
558 Views
I am still very new to Swift. Now I am learning about storyboards. I added two View Controllers to the app by using the + icon in Xcode's Title Bar. Added one button to each of their screens, and then added a connectors (segues) between them, so that each button would navigate to the other screen. As soon as these connectors are added, each segue gets the error: /Users/ ... /LaunchScreen.storyboard Launch screens may not have triggered segues. So I figured at first that the first screen I added to the project by means of adding a View Controller must have been launch screen. So I remove the segues, I add two more screens in the same way, and make the same connections between these two new screens. The same errors appeared. It appears to me that Xcode considers every new screen added by dragging in a View Controller is a launch screen. How do I make only the first screen the "Launch Screen"?
Posted
by spflanze.
Last updated
.
Post not yet marked as solved
3 Replies
635 Views
On the 4th question of: https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/NetServices/Articles/faq.html I see: "you can ask the Bonjour to reconfirm the record" I am basing my code on the TicTacToe example at: https://developer.apple.com/videos/play/wwdc2022/110339/ I believe the DNS records which remains after the device that put them there shuts down is causing problems for me when again. Using the DeviceDiscoveryUI as in that TicTacToe example how are these records "reconfirmed" ?
Posted
by spflanze.
Last updated
.
Post not yet marked as solved
1 Replies
309 Views
To learn how to do peer to peer communication I downloaded the TicTacToe example into my MacStudio from: https://developer.apple.com/documentation/network/building_a_custom_peer-to-peer_protocol I then loaded it into Xcode, compiled it, deployed to an iPhone 14 over a Lightning cable, and ran it. I developed code for the MacStudio in an attempt to communicate with it. The MacStudio at first detected the service but for some reason it has quit doing so. The command: dns-sd -B _services._dns-sd._udpoutputs this as one of its lines: A/R Flags if Domain Service Type Instance Name Add 3 17 . tcp.local. _tictactoe (The time stamp column deleted for clarity) This line remains the command's output even after the iPhone the TicTacToe app has been shutdown, and after in the MacStudio Xcode, and the simulator it opens, is shutdown. In an attempt to find out what application is still advertising this Bonjour service I installed Discovery from: https://apps.apple.com/us/app/discovery-dns-sd-browser/id305441017 When run the _tictactoe service instance does show in its list also also. But when I left click this item in that list to get a detail view of it I get a perpetual spinning wheel, and just to the right of it the message "Scanning...". No information is displayed. What does that mean in regard to what program is still advertising this service? What other ways are available to find this program so it can be shut down? Is it possible that this presence in that list, and in the output of the dns-sd is just a phantom vestige of an application that is not longer running? If this is a case how can the service offering be shutdown?
Posted
by spflanze.
Last updated
.
Post not yet marked as solved
1 Replies
688 Views
Is there a setting in the iPhone 14's iOS that allows the flashlight (torch) remain on simultaneously with the camera taking a still shot? If not, is there an app that can do that?
Posted
by spflanze.
Last updated
.
Post not yet marked as solved
0 Replies
217 Views
On my MacStudio there are applications that start up when on login. I need to these not to be. No applications show up at: System Settings => General => Login Items Where else is there to look? The startup apps that are opening are: iPhone 14 Pro simulator Activity Monitor I believe the simulator is opening because I have been developing an iPhone 14 app with XCode. But once started, somehow, like the Sorcerer's Apprentice's brooms, it just keeps on appearing on its own, even if I have closed both it, and XCode, before shutdown. So now, to keep this off at startup, I need a sorcerer?
Posted
by spflanze.
Last updated
.
Post not yet marked as solved
0 Replies
277 Views
Is there an easy way to convert a storyboard made for iOS to one made for a Mac? Failing that, is there an easy way to convert a storyboard to SwiftUI?
Posted
by spflanze.
Last updated
.