swift4.2

Type 'NSNotification.Name' has no member 'UITextField'

邮差的信 提交于 2020-08-01 01:11:03
问题 With Swift 4.2, getting following error, that was working fine with Swift 4. Type 'NSNotification.Name' has no member 'UITextField' Here is my error code. NotificationCenter.default.addObserver(forName: NSNotification.Name.UITextField.textDidChangeNotification, object: textField, queue: OperationQueue.main) { (notification) in loginAction.isEnabled = textField.text != "" } Full Code: @IBAction func alertWithLogin(){ let alertController = UIAlertController(title: "Please Enter Credential",

Type 'NSNotification.Name' has no member 'UITextField'

馋奶兔 提交于 2020-08-01 01:09:43
问题 With Swift 4.2, getting following error, that was working fine with Swift 4. Type 'NSNotification.Name' has no member 'UITextField' Here is my error code. NotificationCenter.default.addObserver(forName: NSNotification.Name.UITextField.textDidChangeNotification, object: textField, queue: OperationQueue.main) { (notification) in loginAction.isEnabled = textField.text != "" } Full Code: @IBAction func alertWithLogin(){ let alertController = UIAlertController(title: "Please Enter Credential",

Type 'NSNotification.Name' has no member 'UITextField'

北城余情 提交于 2020-08-01 01:09:10
问题 With Swift 4.2, getting following error, that was working fine with Swift 4. Type 'NSNotification.Name' has no member 'UITextField' Here is my error code. NotificationCenter.default.addObserver(forName: NSNotification.Name.UITextField.textDidChangeNotification, object: textField, queue: OperationQueue.main) { (notification) in loginAction.isEnabled = textField.text != "" } Full Code: @IBAction func alertWithLogin(){ let alertController = UIAlertController(title: "Please Enter Credential",

How to write the access for camera

时光总嘲笑我的痴心妄想 提交于 2020-07-23 11:07:26
问题 Actually I am trying to implement a QR APP ,for that I am trying to add the permissions to access camera and I have written the permissions even though that permission alert is not coming .Can anyone help me out to do this.Thanks in advance. 回答1: Add this code in your view controller class import AVFoundation //Barcode Scanner let captureSession = AVCaptureSession() var videoPreviewLayer: AVCaptureVideoPreviewLayer! var initialized = false let barCodeTypes = [AVMetadataObject.ObjectType.upce,

How to write the access for camera

落花浮王杯 提交于 2020-07-23 11:07:11
问题 Actually I am trying to implement a QR APP ,for that I am trying to add the permissions to access camera and I have written the permissions even though that permission alert is not coming .Can anyone help me out to do this.Thanks in advance. 回答1: Add this code in your view controller class import AVFoundation //Barcode Scanner let captureSession = AVCaptureSession() var videoPreviewLayer: AVCaptureVideoPreviewLayer! var initialized = false let barCodeTypes = [AVMetadataObject.ObjectType.upce,

How to write the access for camera

被刻印的时光 ゝ 提交于 2020-07-23 11:05:09
问题 Actually I am trying to implement a QR APP ,for that I am trying to add the permissions to access camera and I have written the permissions even though that permission alert is not coming .Can anyone help me out to do this.Thanks in advance. 回答1: Add this code in your view controller class import AVFoundation //Barcode Scanner let captureSession = AVCaptureSession() var videoPreviewLayer: AVCaptureVideoPreviewLayer! var initialized = false let barCodeTypes = [AVMetadataObject.ObjectType.upce,

DispatchQueue : Cannot be called with asCopy = NO on non-main thread

不问归期 提交于 2020-06-24 10:58:28
问题 I am presenting the UIAlertController on the main thread as : class HelperMethodClass: NSObject { class func showAlertMessage(message:String, viewController: UIViewController) { let alertMessage = UIAlertController(title: "", message: message, preferredStyle: .alert) let cancelAction = UIAlertAction(title: "Ok", style: .cancel) alertMessage.addAction(cancelAction) DispatchQueue.main.async { viewController.present(alertMessage, animated: true, completion: nil) } } } And I am calling the method

Show JSON as TableView Section and TableView row in Swift 4.2 without Decodable?

天涯浪子 提交于 2020-06-23 14:16:06
问题 I have below JSON response array with key "events" { "events": [ { "name": "event foo", "date": "2020-05-22", "time": "7:00", "am_or_pm": "PM", "day": "Saturday", "description": "test " }, { "name": "event bar", "date": "2020-05-22", "time": "7:00", "am_or_pm": "PM", "day": "Saturday", "description": "test2" }, { "name": "event foobar", "date": "2020-05-24", "time": "11:00", "am_or_pm": "PM", "day": "Saturday", "description": "test3" }, { "name": "event foobar", "date": "2020-05-24", "time":

How to crop wide images in swift without stretching

时光怂恿深爱的人放手 提交于 2020-03-21 04:27:50
问题 I am having trouble cropping pictures taken to be of an exact size that is in the wide format. For instance I take a picture with an iPad front camera, which has the resolution of 960w,1280h and I need to crop to be exactly 875w,570h. I tried some of the methods in here, but they all stretch the image or don't get the size I want. Here is the first method that I tried: func cropToBounds(image: UIImage, width: Double, height: Double) -> UIImage { let cgimage = image.cgImage! let contextImage:

How to crop wide images in swift without stretching

人盡茶涼 提交于 2020-03-21 04:27:26
问题 I am having trouble cropping pictures taken to be of an exact size that is in the wide format. For instance I take a picture with an iPad front camera, which has the resolution of 960w,1280h and I need to crop to be exactly 875w,570h. I tried some of the methods in here, but they all stretch the image or don't get the size I want. Here is the first method that I tried: func cropToBounds(image: UIImage, width: Double, height: Double) -> UIImage { let cgimage = image.cgImage! let contextImage: