I do not know what I did to make it so, but somehow I accidentally got Xcode Interface Builder to display a storyboard file in an undesired mode which displays the UI buttons, and text fields, in rectangles as shown in the screenshot below. How do I reverse what I did to get it out of this mode?
Post
Replies
Boosts
Views
Activity
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?
The need is to persist between launches the state of storyboard objects such as of type UISwitch, UITextField, etc. Can this be done using @AppStorage? If so how can @AppStorage be set to watch these?
I tried getting @AppStorage to watch an outlet class member variable that is connected to the storyboard object:
@IBOutlet weak var iPhoneName: UITextField!
@AppStorage("iPhoneName") var iPhoneName: String = ""
This got an error because the variable to be watched is already declared.
I decided to make the the watched variable different than the one connected to the Storyboard's UITextField object:
@AppStorage("iPhoneName") var striPhoneName: String = ""
and got the error: Unknown attribute 'AppStorage' . In what import library is @AppStorage defined?
If @AppStorage cannot be used for this, what is the easiest way to code storyboard object persistence? I am looking for an easy, and quick way. I am not concerned with memory usage right now.
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?
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?
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?
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.
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.
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"?
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?
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" ?
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?
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?
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?
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?