Post

Replies

Boosts

Views

Activity

How to bring custom toastView above keypad in swift?
I trying to display toast on bottom of screen but, when keypad appears toast is hiding behind keypad. Please any one suggest me the solution. Below is my code which i tried. func displayToast(_ message : String) { guard let delegate = UIApplication.shared.delegate as? AppDelegate, let window = delegate.window else { return } if let toast = window.subviews.first(where: { $0 is UILabel && $0.tag == -1001 }) { toast.removeFromSuperview() } let toastView = UILabel() toastView.backgroundColor = UIColor.black.withAlphaComponent(0.7) toastView.textColor = UIColor.white toastView.textAlignment = .center toastView.font = UIFont(name: "Font-name", size: 17) toastView.layer.cornerRadius = 15 toastView.clipsToBounds = true toastView.text = message toastView.numberOfLines = 0 toastView.alpha = 0 toastView.translatesAutoresizingMaskIntoConstraints = false toastView.tag = -1001 let windowww = UIApplication.shared.windows[UIApplication.shared.windows.count - 1] windowww.addSubview(toastView) let horizontalCenterContraint: NSLayoutConstraint = NSLayoutConstraint(item: toastView, attribute: .centerX, relatedBy: .equal, toItem: windowww, attribute: .centerX, multiplier: 1, constant: 0) let widthContraint: NSLayoutConstraint = NSLayoutConstraint(item: toastView, attribute: .width, relatedBy: .equal, toItem: nil, attribute: .width, multiplier: 1, constant: (self.frame.size.width-25) ) let verticalContraint: [NSLayoutConstraint] = NSLayoutConstraint.constraints(withVisualFormat: "V:|-(>=200)-[toastView(==50)]-68-|", options: [.alignAllCenterX, .alignAllCenterY], metrics: nil, views: ["toastView": toastView]) NSLayoutConstraint.activate([horizontalCenterContraint, widthContraint]) NSLayoutConstraint.activate(verticalContraint) UIView.animate(withDuration: 0.5, delay: 0, options: .curveEaseIn, animations: { toastView.alpha = 1 }, completion: nil) DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(3), execute: { UIView.animate(withDuration: 0.5, delay: 0, options: .curveEaseIn, animations: { toastView.alpha = 0 }, completion: { finished in toastView.removeFromSuperview() }) }) }
1
0
1.1k
Sep ’23
Restrict to UITextField cursor should only focus on end of text
I need to restrict to UITextField text cursor should only focus on end of text every time. Ex- if user entered OTP in textField and again he want to replace digit from text field when he tap to UITextField then cursor should focus on end of text only not beginning of text. I added below code func textFieldDidBeginEditing(_ textField: UITextField){ DispatchQueue.main.async{ let position = textField.endOfDocument textField.selectedTextRange = textField.textRange(from: position, to: position) } } It is working On first time textfield selection. After once cursor focussed in UITextField that time it is moving to Start position if user tap on start position.
1
0
2.4k
Sep ’23
How to programatically update latest version of iOS App without redirecting App Store?
Hi, I am trying to download and automatically update latest version of iOS app from app store programmatically without redirect user to app store. Please any one help me to how to achieve.
Replies
0
Boosts
0
Views
409
Activity
Jun ’23
How to connect iPhone X hotspot to MI 7s mobile
Hi, I am trying to connect iPhone hotspot to Android phone. But it is not connecting. Please help me to connect hotspot. Thanks.
Replies
0
Boosts
0
Views
450
Activity
Aug ’23
Which architecture is best for SuiftUI project?
Hi, I am going to start develop new project in SwiftUI. Please any one help me to which architecture is good for SwiftUI project. Thank you.
Replies
4
Boosts
0
Views
1.8k
Activity
Aug ’23
How to bring custom toastView above keypad in swift?
I trying to display toast on bottom of screen but, when keypad appears toast is hiding behind keypad. Please any one suggest me the solution. Below is my code which i tried. func displayToast(_ message : String) { guard let delegate = UIApplication.shared.delegate as? AppDelegate, let window = delegate.window else { return } if let toast = window.subviews.first(where: { $0 is UILabel && $0.tag == -1001 }) { toast.removeFromSuperview() } let toastView = UILabel() toastView.backgroundColor = UIColor.black.withAlphaComponent(0.7) toastView.textColor = UIColor.white toastView.textAlignment = .center toastView.font = UIFont(name: "Font-name", size: 17) toastView.layer.cornerRadius = 15 toastView.clipsToBounds = true toastView.text = message toastView.numberOfLines = 0 toastView.alpha = 0 toastView.translatesAutoresizingMaskIntoConstraints = false toastView.tag = -1001 let windowww = UIApplication.shared.windows[UIApplication.shared.windows.count - 1] windowww.addSubview(toastView) let horizontalCenterContraint: NSLayoutConstraint = NSLayoutConstraint(item: toastView, attribute: .centerX, relatedBy: .equal, toItem: windowww, attribute: .centerX, multiplier: 1, constant: 0) let widthContraint: NSLayoutConstraint = NSLayoutConstraint(item: toastView, attribute: .width, relatedBy: .equal, toItem: nil, attribute: .width, multiplier: 1, constant: (self.frame.size.width-25) ) let verticalContraint: [NSLayoutConstraint] = NSLayoutConstraint.constraints(withVisualFormat: "V:|-(>=200)-[toastView(==50)]-68-|", options: [.alignAllCenterX, .alignAllCenterY], metrics: nil, views: ["toastView": toastView]) NSLayoutConstraint.activate([horizontalCenterContraint, widthContraint]) NSLayoutConstraint.activate(verticalContraint) UIView.animate(withDuration: 0.5, delay: 0, options: .curveEaseIn, animations: { toastView.alpha = 1 }, completion: nil) DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(3), execute: { UIView.animate(withDuration: 0.5, delay: 0, options: .curveEaseIn, animations: { toastView.alpha = 0 }, completion: { finished in toastView.removeFromSuperview() }) }) }
Replies
1
Boosts
0
Views
1.1k
Activity
Sep ’23
How to store user activities log in iOS app
Hi, I am trying to store user activities log in text file and once the session is over in another session the log will override the file automatically. Please any one help me to implement without using third party analytics library. Only using Apple class. Thank you.
Replies
1
Boosts
0
Views
680
Activity
Sep ’23
Restrict to UITextField cursor should only focus on end of text
I need to restrict to UITextField text cursor should only focus on end of text every time. Ex- if user entered OTP in textField and again he want to replace digit from text field when he tap to UITextField then cursor should focus on end of text only not beginning of text. I added below code func textFieldDidBeginEditing(_ textField: UITextField){ DispatchQueue.main.async{ let position = textField.endOfDocument textField.selectedTextRange = textField.textRange(from: position, to: position) } } It is working On first time textfield selection. After once cursor focussed in UITextField that time it is moving to Start position if user tap on start position.
Replies
1
Boosts
0
Views
2.4k
Activity
Sep ’23
How to scan credit card using camera swift
I trying to scan credit card but i am getting some issue with printed( Pressed ) number on card and some dark background with dark card numbers as well not scanning. Please help me to smooth scan for every cards. Thanks.
Replies
0
Boosts
0
Views
1.1k
Activity
Sep ’23