When I try to press on any button on my calculator it gives me the error unrecognized selector sent to instance 0x7f7f85e04e40 I updated this code from Swift 2 to Swift 4 but back then it used to work. What's wrong with the code?
import UIKit
class Valuta: UIViewController {
#IBOutlet weak var euro: UILabel!
#IBOutlet weak var zloty: UILabel!
#IBOutlet weak var topButton: UIButton!
#IBOutlet weak var bottomButton: UIButton!
var valutas : [ValutaWaarde] = []
var number = 0;
var isTypingNumber = false
var currentNumber = 0;
var currency = "PLN";
#IBAction func numberTapped(sender: AnyObject) {
let number = sender.currentTitle!
var disable = false
if number == "."{
if euro.text!.range(of: ".") != nil{
disable = true
}
}
if(disable == false){
if isTypingNumber {
euro.text = euro.text!+number!
} else {
euro.text = number
isTypingNumber = true
}
var output : Float;
if(currency == "EUR"){
output = (euro.text! as NSString).floatValue*Float((valutas[0].rates?.pLN!)!)
}
else{
output = (euro.text! as NSString).floatValue/Float((valutas[0].rates?.pLN!)!)
}
zloty.text = String(format: "%.2f", output)
}
}
#IBAction func resetCalculator(sender: AnyObject) {
isTypingNumber = false;
zloty.text = "0";
euro.text = "0";
}
override func viewDidLoad() {
super.viewDidLoad()
UINavigationBar.appearance().isTranslucent = false;
UINavigationBar.appearance().barTintColor = UIColor(red: CGFloat(51/255.0), green: 51/255, blue: 51/255, alpha: 1)
UINavigationBar.appearance().titleTextAttributes = [NSAttributedStringKey.foregroundColor:UIColor.white]
//Get list
let url = URL(string: "https://api.fixer.io/latest?symbols=PLN&base=EUR")
var request = NSMutableURLRequest(url: url! as URL, cachePolicy: NSURLRequest.CachePolicy.returnCacheDataElseLoad, timeoutInterval: Double.infinity)
if Reachability.isConnectedToNetwork(){
request = NSMutableURLRequest(url: url! as URL, cachePolicy: NSURLRequest.CachePolicy.useProtocolCachePolicy, timeoutInterval: Double.infinity);
}
let session = URLSession.shared
let task = session.dataTask(with: request as URLRequest,
completionHandler: { data, response, error -> Void in
do {
if let json = try JSONSerialization.jsonObject(with: data!) as? [[String: String]] {
for valutaData in json {
let valuta = ValutaWaarde(dictionary: valutaData as NSDictionary)
self.valutas.append(valuta!)
}
}
} catch { print(error) }
})
task.resume()
}
...
}
Try to re-connect #IBOutlets and #IBActions in storyboard.
Related
I have a problem.
I've implemented the visionkit framework in order to detect a text when the camera is used.
The problem is that the colors of the buttons: "Keep Scan" and "Retake" are blue. I want them in black color. How can I fix this problem? I paste my code.
Thank you in advance!
import UIKit
import Vision
import VisionKit
class ScanText: UIViewController, VNDocumentCameraViewControllerDelegate {
#IBOutlet weak var imageView: UIImageView!
#IBOutlet weak var TextScan: UITextView!
#IBOutlet weak var buttonStartShape: UIButton!
#IBOutlet weak var infoScattaUnaFoto: UILabel!
#IBOutlet weak var copyButtonShape: UIButton!
var textRecognitionRequest = VNRecognizeTextRequest(completionHandler: nil)
private let textRecognitionWorkQueue = DispatchQueue(label: "MyVisionScannerQueue", qos: .userInitiated, attributes: [], autoreleaseFrequency: .workItem)
var classView = ViewController()
var arrayText = String()
override func viewDidLoad() {
super.viewDidLoad()
imageView.layer.cornerRadius = 15
imageView.clipsToBounds = true
TextScan.layer.cornerRadius = 15
TextScan.clipsToBounds = true
copyButtonShape.layer.cornerRadius = 25
copyButtonShape.clipsToBounds = true
buttonStartShape.layer.cornerRadius = 25
buttonStartShape.clipsToBounds = true
TextScan.isEditable = true
setupVision()
}
#IBAction func TakePicture(_ sender: Any) {
let scannerViewController = VNDocumentCameraViewController()
scannerViewController.delegate = self
present(scannerViewController, animated: true)
}
private func setupVision() {
textRecognitionRequest = VNRecognizeTextRequest { (request, error) in
guard let observations = request.results as? [VNRecognizedTextObservation] else { return }
var detectedText = ""
for observation in observations {
guard let topCandidate = observation.topCandidates(2).first else { return }
print("text \(topCandidate.string) has confidence \(topCandidate.confidence)")
detectedText += topCandidate.string
detectedText += "\n"
}
DispatchQueue.main.async {
self.TextScan.isHidden = false
self.infoScattaUnaFoto.isHidden = true
self.copyButtonShape.isHidden = false
self.buttonStartShape.setTitle("Ripeti", for: .normal)
self.TextScan.text += detectedText
self.TextScan.flashScrollIndicators()
}
}
textRecognitionRequest.recognitionLevel = .accurate
}
private func processImage(_ image: UIImage) {
imageView.image = image
recognizeTextInImage(image)
}
private func recognizeTextInImage(_ image: UIImage) {
guard let cgImage = image.cgImage else { return }
TextScan.text = ""
textRecognitionWorkQueue.async {
let requestHandler = VNImageRequestHandler(cgImage: cgImage, options: [:])
do {
try requestHandler.perform([self.textRecognitionRequest])
} catch {
print(error)
}
}
}
func documentCameraViewController(_ controller: VNDocumentCameraViewController, didFinishWith scan: VNDocumentCameraScan) {
/* guard scan.pageCount >= 1 else {
controller.dismiss(animated: true)
return
}*/
for i in 0 ..< scan.pageCount {
let img = scan.imageOfPage(at: i)
processImage(img)
}
let originalImage = scan.imageOfPage(at: 0)
print(originalImage)
//let newImage = compressedImage(originalImage)
controller.dismiss(animated: true)
}
func documentCameraViewController(_ controller: VNDocumentCameraViewController, didFailWithError error: Error) {
print(error)
controller.dismiss(animated: true)
}
func documentCameraViewControllerDidCancel(_ controller: VNDocumentCameraViewController) {
controller.dismiss(animated: true)
}
func compressedImage(_ originalImage: UIImage) -> UIImage {
guard let imageData = originalImage.jpegData(compressionQuality: 1),
let reloadedImage = UIImage(data: imageData) else {
return originalImage
}
return reloadedImage
}
//MARK: By tapping on this button, I pass all the data.
#IBAction func CopyText(_ sender: Any) {
let vc = (storyboard?.instantiateViewController(identifier: "SpeakDetail") as? ViewController)!
vc.textscannerized = TextScan.text
self.navigationController?.pushViewController(vc, animated: true)
}
}
You can try something like this:
scannerViewController.view.tintColor = .red
I was wondering if I could ask a question regarding csv/http posting. I want my data to update within my app after I pull the data from my github csv file, but when I do, it doesn't update within the app but just prints the numbers. What's wrong with my code? Thanks!
class NewStats: UITableViewController {
var didTapMenuType: ((NewMenu) -> Void)?
var Num2:String = "2"
#IBOutlet weak var MultnomahText: UILabel!
#IBOutlet weak var MultnomahView: UIProgressView!
override func viewDidLoad() {
let url = URL(string: "SampleUrl.csv")!
let task = URLSession.shared.dataTask(with: url) {(data, response, error) in
guard let data = data else { return }
let str = (String(data: data, encoding: .utf8)!)
let fullNameArr = str.components(separatedBy: ",")
let Num1 = fullNameArr[0]
self.Num2 = fullNameArr[1]
let Num3 = fullNameArr[2]
let Num4 = fullNameArr[3]
let Num5 = fullNameArr[4]
let Num6 = fullNameArr[5]
let Num7 = fullNameArr[6]
let Num8 = fullNameArr[7]
let Num9 = fullNameArr[8]
let Num10 = fullNameArr[9]
print(Num1);
print(self.Num2);
print(Num3);
print(Num4);
print(Num5);
print(Num6);
print(Num7);
print(Num8);
print(Num9);
print(Num10);
}
task.resume()
super.viewDidLoad()
DispatchQueue.main.async {
self.tableView.reloadData()
}
print(self.Num2);
self.MultnomahText.text = "Multnomah:" + self.Num2
self.MultnomahView.setProgress(0.5, animated: true)
}
After the print(Num10)
DispatchQueue.main.async {
self.MultnomahText.text = "Multnomah:" + self.Num2
self.MultnomahView.setProgress(0.5, animated: true)
self.tableView.reloadData()
}
Hopefully this helps!
I want to use variables (depAirportLat and depAirportLong) outside ViewController class in order to display coordinates on a map but it doesn't works, could you help me ? This is my program :
import UIKit
import MapKit
class ViewController: UIViewController, UITextFieldDelegate {
#IBOutlet weak var resultWeather: UIImageView!
#IBOutlet weak var arrairport: UITextField!
#IBOutlet weak var depairport: UITextField!
#IBOutlet weak var resultAirport: UILabel!
#IBOutlet weak var fontAirports: UIImageView!
#IBOutlet weak var resultTemp: UILabel!
#IBOutlet weak var resultTempfar: UILabel!
#IBOutlet weak var resultHum: UILabel!
#IBOutlet weak var resultCeiling: UILabel!
#IBOutlet weak var resultClouds: UILabel!
#IBOutlet weak var resultWind: UILabel!
#IBOutlet weak var resultPressure: UILabel!
#IBOutlet weak var resultMetar: UILabel!
#IBOutlet weak var resultTaf: UILabel!
#IBOutlet weak var arrMap: MKMapView!
#IBOutlet weak var depMap: MKMapView!
#IBAction func getWeather(_ sender: UIButton) {
sender.pulsate()
if let url = URL(string: "http://fr.allmetsat.com/metar-taf/france.php?icao=" + depairport.text!.replacingOccurrences(of: " ", with: "-"))
{ let request = NSMutableURLRequest(url: url)
let task = URLSession.shared.dataTask(with: request as URLRequest) { data, response, error in
var message = ""
if error != nil { print(error!) } else { if let unwrappedData = data {
let dataString = NSString(data: unwrappedData, encoding: String.Encoding.utf8.rawValue); var stringSeparator = "METAR:</b> "
if let contentArray = dataString?.components(separatedBy: stringSeparator) {
if contentArray.count > 1 { stringSeparator = "</p></div><div class=\"c1\""
let newContentArray = contentArray[1].components(separatedBy: stringSeparator); if newContentArray.count > 1 { message = newContentArray[0]
print(message)
if (dataString?.contains("CAVOK"))!{
DispatchQueue.main.async { self.resultWeather.image = UIImage(named: "sun.png") }}
else if (dataString?.contains("SKC"))!{
DispatchQueue.main.async { self.resultWeather.image = UIImage(named: "sun.png")}
}
else if (dataString?.contains("SCT"))!{
DispatchQueue.main.async { self.resultWeather.image = UIImage(named: "scattered.png")} }
else if (dataString?.contains("OVC"))!{
DispatchQueue.main.async { self.resultWeather.image = UIImage(named: "overcast.png")} }
else if (dataString?.contains("BKN"))!{
DispatchQueue.main.async { self.resultWeather.image = UIImage(named: "broken.png")} }
else if (dataString?.contains("FEW"))!{
DispatchQueue.main.async { self.resultWeather.image = UIImage(named: "few.png")} }
else if (dataString?.contains("NSC"))!{
DispatchQueue.main.async { self.resultWeather.image = UIImage(named: "sun.png")} }
else if (dataString?.contains("RAIN"))!{
DispatchQueue.main.async { self.resultWeather.image = UIImage(named: "rain.png")}
}}}}}}
}
task.resume();
if let url = URL(string: "http://fr.allmetsat.com/metar-taf/france.php?icao=" + self.depairport.text!.replacingOccurrences(of: " ", with: "-"))
{ let requesta = NSMutableURLRequest(url: url)
let taska = URLSession.shared.dataTask(with: requesta as URLRequest) { data, response, error in
var messagea = ""
if error != nil { print(error!) } else { if let unwrappedData = data {
let dataStringa = NSString(data: unwrappedData, encoding: String.Encoding.utf8.rawValue); var stringSeparatora = "<div class=\"c1b\""
if let contentArray = dataStringa?.components(separatedBy: stringSeparatora) { if contentArray.count > 1 { stringSeparatora = "</h1><p>"
let newContentArray = contentArray[1].components(separatedBy: stringSeparatora); if newContentArray.count > 1 { messagea = newContentArray[0]
print(messagea) }}}};
}
if messagea == "" { messagea = "No data..." }
DispatchQueue.main.sync(execute: { self.resultAirport.text = self.depairport.text! })}; taska.resume() } else { self.resultAirport.text = "0" };
//latitude variable (depAirportLat)
if let urlcoord = URL(string:"https://flyawaysimulation.com/airports/" + self.depairport.text!.replacingOccurrences(of: " ", with: "-"))
{ let requestad = NSMutableURLRequest(url: urlcoord)
let taskad = URLSession.shared.dataTask(with: requestad as URLRequest) { data, response, error in
var depAirportLat = ""
if error != nil { print(error!) } else { if let unwrappedData = data {
let dataStringad = NSString(data: unwrappedData, encoding: String.Encoding.utf8.rawValue); var stringSeparatorad = "<dt>Latitude</dt>"
if let contentArray = dataStringad?.components(separatedBy: stringSeparatorad) { if contentArray.count > 1 { stringSeparatorad = "</dd>"
let newContentArray = contentArray[1].components(separatedBy: stringSeparatorad); if newContentArray.count > 1 { depAirportLat = newContentArray[0]
print(depAirportLat) }}}}}};
taskad.resume()
}
}
override func viewDidLoad() {
super.viewDidLoad()
//Do any additional setup after loading the view, typically from a nib.
class gloVarDep {
var depAirportLatReal = depAirportLat.dropFirst(5)
var depAirportLatRealCoord = String(depAirportLatReal)
var depAirportLatRealCoordFloat = (depAirportLatRealCoord as NSString).floatValue
If you want to be able to use those variables outside the class, then you have to declare them as global variables. Just declare them outside of the class scope and you should be fine.
Alternatively, you could create a structure and define static variables that can be used everywhere. The aforementioned makes things a bit more readable and retainable.
I'm trying to capture a user input (textfield + button) and reuse the result later in the program but I don't know how to do that.
import UIKit
class ViewController: UIViewController {
#IBOutlet weak var resultLabel: UILabel!
#IBOutlet weak var moneyTextField: UITextField!
#IBAction func convert(_ sender: Any) {
let convertion:Double = Double(moneyTextField.text!)!
print(convertion)
}
override func viewDidLoad() {
super.viewDidLoad()
let url = URL(string: "https://www.x-rates.com/calculator/?from=EUR&to=USD&amount=1")!
let request = NSMutableURLRequest(url : url)
let task = URLSession.shared.dataTask(with: request as URLRequest) {
data, response, error in
var rateValue:Double = 0.0;
if let error = error {
print(error)
} else {
if let unwrappedData = data {
let dataString = NSString(data: unwrappedData, encoding: String.Encoding.utf8.rawValue)
var stringSeperator = "<span class=\"ccOutputRslt\">"
if let contentArray = dataString?.components(separatedBy: stringSeperator){
if contentArray.count > 0 {
stringSeperator = "<span"
let newContentArray = contentArray[1].components(separatedBy: stringSeperator)
if newContentArray.count > 0 {
rateValue = Double(newContentArray[0])!
print(newContentArray[0])
}
}
}
}
}
//
print("Rate is \(rateValue)");
DispatchQueue.main.sync(execute: {
self.resultLabel.text = "the value of the dollar is " + String(rateValue)
}
)}
task.resume()
}
}
What I want to do is take the let convertion and multiply it by rateValue at the end of the code. I tried different thing but without any results.
after the advice from Joakim Danielson
I did that :
import UIKit
class ViewController: UIViewController {
var fxRate: Double?
#IBOutlet weak var resultLabel: UILabel!
#IBOutlet weak var moneyTextField: UITextField!
#IBAction func convert(_ sender: Any) {
let convertion:Double = Double(moneyTextField.text!)!
print(convertion)
var convertedAmount = 0.0
if let rate = fxRate, let money = Double(moneyTextField.text) {
convertedAmount = rate * money
}
print(convertedAmount)
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let url = URL(string: "https://www.x-rates.com/calculator/?from=EUR&to=USD&amount=1")!
let request = NSMutableURLRequest(url : url)
let task = URLSession.shared.dataTask(with: request as URLRequest) {
data, response, error in
var rateValue:Double = 0.0;
if let error = error {
print(error)
} else {
if let unwrappedData = data {
let dataString = NSString(data: unwrappedData, encoding: String.Encoding.utf8.rawValue)
var stringSeperator = "<span class=\"ccOutputRslt\">"
if let contentArray = dataString?.components(separatedBy: stringSeperator){
if contentArray.count > 0 {
stringSeperator = "<span"
let newContentArray = contentArray[1].components(separatedBy: stringSeperator)
if newContentArray.count > 0 {
rateValue = Double(newContentArray[0])!
print(newContentArray[0])
rateValue = Double(newContentArray[0])!
self.fxRate = rateValue
}
}
}
}
}
//
print("Rate is \(rateValue)");
DispatchQueue.main.sync(execute: {
self.resultLabel.text = "the value of the dollar is " + String(rateValue)
}
)}
task.resume()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
but I have the error : Cannot invoke initializer for type 'Double' with an argument list of type '(String?)' on line 26. Can you please help me? thx!
create a variable outside of your function
var anyVariableYouWantToAccessLater: Double?
And use this variable anywhere you want.
Since you're downloading the rate during viewDidLoad I am assuming this is what you want to keep.
Add a new property to the class
class ViewController: UIViewController {
var fxRate: Double?
...
In viewDidLoad update this property with the downloaded value
rateValue = Double(newContentArray[0])!
fxRate = rateValue
In the convert func (or wherever you want to use the rate)
#IBAction func convert(_ sender: Any) {
var convertedAmount = 0.0
if let rate = fxRate, let money = Double(moneyTextField.text ?? "0") {
convertedAmount = rate * money
}
print(convertedAmount)
}
I made a live translation app that identifies an object and translates it using the user's camera. It works just fine on my iPhone 6s and doesn't crash in any of the simulators, but when I run it on an iPhone 6, it crashes as soon I try to segue to the camera feed. Apple also says it crashes on the iPad as well.
Do certain devices just not support Vision API or is something wrong with my code?
import UIKit
import AVKit
import Vision
var lang = ""
var lang2 = ""
class ViewController: UIViewController, AVCaptureVideoDataOutputSampleBufferDelegate, AVCapturePhotoCaptureDelegate {
#IBAction func screenshotB(_ sender: Any) {
//screenshot camera screen view
}
#IBOutlet weak var screenshotBOutlet: UIButton!
#IBOutlet weak var swirlyGuy: UIActivityIndicatorView!
#IBOutlet weak var title1: UILabel!
#IBOutlet weak var settingsButtonOutlet: UIButton!
#IBOutlet weak var launchScreen: UIViewX!
#IBOutlet weak var launchScreenLogo: UIImageView!
func stopSwirlyGuy(){
swirlyGuy.stopAnimating()
}
let identifierLabel: UILabel = {
let label = UILabel()
label.backgroundColor = UIColor(red: 0, green: 0, blue:0, alpha: 0.4)
label.textColor = .white
label.textAlignment = .center
label.translatesAutoresizingMaskIntoConstraints = false
return label
}()
#IBAction func prepareForUnwind (segue:UIStoryboardSegue) {
}
override func viewDidLoad() {
super.viewDidLoad()
launchScreen.alpha = 1
launchScreenLogo.alpha = 1
swirlyGuy.startAnimating()
// start up the camera
let captureSession = AVCaptureSession()
captureSession.sessionPreset = .hd4K3840x2160
guard let captureDevice = AVCaptureDevice.default(for: .video) else { return }
guard let input = try? AVCaptureDeviceInput(device: captureDevice) else { return }
captureSession.addInput(input)
captureSession.startRunning()
let previewLayer = AVCaptureVideoPreviewLayer(session: captureSession)
view.layer.addSublayer(previewLayer)
previewLayer.frame = view.frame
let dataOutput = AVCaptureVideoDataOutput()
dataOutput.setSampleBufferDelegate(self, queue: DispatchQueue(label: "videoQueue"))
captureSession.addOutput(dataOutput)
setupIdentifierConfidenceLabel()
setupSettingsButton()
setupTitle()
setupSwirlyGuy()
setupScreenshot()
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
UIView.animate(withDuration: 1.5) {
self.launchScreen.alpha = 0
self.launchScreenLogo.alpha = 0
}
}
fileprivate func setupSettingsButton() {
view.addSubview(settingsButtonOutlet)
}
fileprivate func setupScreenshot() {
view.addSubview(screenshotBOutlet)
}
fileprivate func setupSwirlyGuy() {
view.addSubview(swirlyGuy)
}
fileprivate func setupTitle() {
view.addSubview(title1)
}
fileprivate func setupIdentifierConfidenceLabel() {
view.addSubview(identifierLabel)
identifierLabel.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true
identifierLabel.leftAnchor.constraint(equalTo: view.leftAnchor).isActive = true
identifierLabel.rightAnchor.constraint(equalTo: view.rightAnchor).isActive = true
identifierLabel.heightAnchor.constraint(equalToConstant: 100).isActive = true
identifierLabel.numberOfLines = 0
}
func captureOutput(_ output: AVCaptureOutput, didOutput sampleBuffer: CMSampleBuffer, from connection: AVCaptureConnection) {
// print("Camera was able to capture a frame:", Date())
guard let pixelBuffer: CVPixelBuffer = CMSampleBufferGetImageBuffer(sampleBuffer) else { return }
// model
guard let model = try? VNCoreMLModel(for: Resnet50().model) else { return }
let request = VNCoreMLRequest(model: model) { (finishedReq, err) in
//perhaps check the err
// print(finishedReq.results)
guard let results = finishedReq.results as? [VNClassificationObservation] else { return }
guard let firstObservation = results.first else { return }
print(firstObservation.identifier, firstObservation.confidence)
let x = (firstObservation.confidence)
let y = (x * 10000).rounded() / 10000
let z = (firstObservation.identifier)
let s = (self.translateSpanish(object1: firstObservation.identifier))
let f = (self.translateFrench(object1: firstObservation.identifier))
// var lang = ""
// var lang2 = ""
if language == "English" {
lang = z
}
else if language == "Spanish" {
lang = s
}
else {
lang = f
}
if language2 == "Spanish" {
lang2 = s
}
else if language2 == "English" {
lang2 = z
}
else {
lang2 = f
}
DispatchQueue.main.async {
self.identifierLabel.text = "\(lang)" + " = " + "\(lang2) \n \(y * 100)% accuracy"
self.stopSwirlyGuy()
}
}
try? VNImageRequestHandler(cvPixelBuffer: pixelBuffer, options: [:]).perform([request])
}
//Translation fucntions omitted for brevity
This is the code for the view controller that segues into the main screen where the camera feed and Vision processing take place.
import UIKit
class FirstLaunchViewController: UIViewController {
#IBOutlet weak var title1: UILabelX!
#IBOutlet weak var logo1: UIImageView!
#IBOutlet weak var description1: UILabel!
#IBOutlet weak var buttonOutlet: UIButtonX!
#IBOutlet weak var initialBackground: UIViewX!
#IBOutlet weak var initialLogo: UIImageView!
#IBAction func toVC(_ sender: Any) {
UserDefaults.standard.set(false, forKey: "name")
performSegue(withIdentifier: "toMain", sender: self)
}
override func viewDidLoad() {
super.viewDidLoad()
initialLogo.alpha = 1
initialBackground.alpha = 1
title1.alpha = 0
logo1.alpha = 0
description1.alpha = 0
buttonOutlet.alpha = 0
// Do any additional setup after loading the view.
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
UIView.animate(withDuration: 1.5, animations: {
self.initialLogo.alpha = 0
self.initialBackground.alpha = 0
}) { (true) in
self.initialBackgroundGone()
}
}
func initialBackgroundGone() {
UIView.animate(withDuration: 1.5, animations: {
self.title1.alpha = 1
}) { (true) in
self.showBackgroundAgain()
}
}
func showBackgroundAgain() {
UIView.animate(withDuration: 1.3, animations: {
self.logo1.alpha = 1
}) { (true) in
self.showTitle()
}
}
func showTitle() {
UIView.animate(withDuration: 1.5, animations: {
self.description1.alpha = 1
}) { (true) in
self.showEverythingElse()
}
}
func showEverythingElse() {
UIView.animate(withDuration: 3.5) {
self.buttonOutlet.alpha = 1
}
}
}
This is a lot of code but I think your issue comes from the video preset your are using as iPhone 6 doesn't have support for 4K video recording.
When setting the session preset you should test that it is supported by all the targeted devices:
if captureSession.canSetSessionPreset(.hd4K3840x2160) {
captureSession.sessionPreset = .hd4K3840x2160
} else {
captureSession.sessionPreset = .high // or any other preset that suits your needs
}