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?
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
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?
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 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?
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 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?
I have a warning message that the method AVCapturePhotoOutput.dngPhotoDataRepresentation is deprecated. What has this method been superseded by?
I tried various ways to instantiate the class: AVCapturePhotoSettings as listed below:
let settings = AVCapturePhotoSettings(format: [ kCVPixelBufferPixelFormatTypeKey : "BGRA"] )
let settings = AVCapturePhotoSettings(format: [ kCVPixelBufferPixelFormatTypeKey as String : "BGRA"] )
let settings = AVCapturePhotoSettings(format: [ String( kCVPixelBufferPixelFormatTypeKey) : "BGRA"]
let settings = AVCapturePhotoSettings(format: [ "kCVPixelBufferPixelFormatTypeKey" : "BGRA"] )
The first method gets the error:
Cannot convert value of type 'CFString' to expected dictionary key type 'String'
and so the three other attempts below this were done, but each of these attempts got the run time error:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** +[AVCapturePhotoSettings photoSettingsWithFormat:] Either kCVPixelBufferPixelFormatTypeKey or AVVideoCodecKey must be specified'
What is the correct way to use this initiator for the class: AVCapturePhotoSettings ?
The need is to capture an image in an uncompressed format, and save it in a lossless file format. I am not particular about which uncompressed format. However AVCapturePhotoOutput.availablePhotoPixelFormatTypes shows that on my iPhone 14 Pro the BGRA format is available, and its type value is: 1111970369. So I use this code to get a settings object, and trigger a photo capture with it:
let settings = AVCapturePhotoSettings(format: [ String( kCVPixelBufferPixelFormatTypeKey ) : 1111970369] )
self.photoOutput?.capturePhoto(with: settings, delegate: self )
I am not sure I have the AVCapturePhotoSettings() dictionary argument right. It is the best I could conclude from available documentation, and it does not produce a compile time error. I found no example how to do uncompress photo files, I found only one that produces jpegs, and I have successfully used that example to capture images in jpeg format. This is the URL for that example which I now attempt to modify to produce uncompressed image files: https://www.appcoda.com/avfoundation-swift-guide/ . This example is somewhat out of date, and some method names had to be changed accordingly.
Next, when the system calls the delegated callback:
func photoOutput(_ output: AVCapturePhotoOutput, didFinishProcessingPhoto photo: AVCapturePhoto, error: Error?)
I need to convert the passed photo.pixelBuffer image object into one I can pass to:
self.photoCaptureCompletionBlock?(image, nil)
Class UIImage(data: data) çannot do this alone. I get a compile time error when I pass photo.pixelBuffer to it. I tried to convert with the AVCapturePhotoOutput() class, but could not a find version of its initiators the compiler would accept to do this.
What do I need to do to get the data in photo.pixelBuffer stored in an uncompressed file?