I’m growing a customized keyboard for iOS.
As many will know, you must embed the keyboard module into an iOS internet hosting app and after the app runs for the primary time, you must set up the keyboard in iOS.
I did all this and the keyboard module seems appropriately when invoked, however that is the issue.
I’m utilizing this code, within the keyboard module, to make it potential to put in writing its view in SwiftUI.
import UIKit
import SwiftUI
class KeyboardViewController: UIInputViewController {
@IBOutlet var nextKeyboardButton: UIButton!
override func viewDidLoad() {
tremendous.viewDidLoad()
let hostingController = UIHostingController(rootView: KeyboardView(viewController: self))
hostingController.view.autoresizingMask = [.flexibleWidth, .flexibleHeight]
view.addSubview(hostingController.view)
addChild(hostingController)
print("....", self.view.bounds)
self.nextKeyboardButton = UIButton(kind: .system)
}
override func viewWillLayoutSubviews() {
tremendous.viewWillLayoutSubviews()
print(self.view.bounds)
}
override func textWillChange(_ textInput: UITextInput?) {
// The app is about to alter the doc's contents. Carry out any preparation right here.
}
override func textDidChange(_ textInput: UITextInput?) {
// The app has simply modified the doc's contents, the doc context has been up to date.
let textColor = self.textDocumentProxy.keyboardAppearance == UIKeyboardAppearance.darkish ? UIColor.white : UIColor.black
self.nextKeyboardButton.setTitleColor(textColor, for: [])
}
}
Then I’ve this code to get the keyboard peak.
struct KeyboardProvider: ViewModifier {
var keyboardHeight: Binding<CGFloat>
func physique(content material: Content material) -> some View {
content material
.onReceive(NotificationCenter.default.writer(for: UIResponder.keyboardWillShowNotification),
carry out: { notification in
guard let userInfo = notification.userInfo,
let keyboardRect = userInfo[UIResponder.keyboardFrameEndUserInfoKey] as? CGRect else { return }
self.keyboardHeight.wrappedValue = keyboardRect.peak
}).onReceive(NotificationCenter.default.writer(for: UIResponder.keyboardWillHideNotification),
carry out: { _ in
self.keyboardHeight.wrappedValue = 0
})
}
}
public extension View {
func keyboardHeight(_ state: Binding<CGFloat>) -> some View {
self.modifier(KeyboardProvider(keyboardHeight: state))
}
}
and I apply it to the keyboard module as this:
@State personal var keyboardHeight: CGFloat = 0
var physique: some View {
Colour.pink
.keyboardHeight($keyboardHeight)
.onChange(of: keyboardHeight) {
print (keyboardHeight)
}
This prints the peak as 852
that’s the full peak of the iPhone 15 I’m testing it.
if I add the identical instruction to the internet hosting app
var physique: some View {
TextField("textField", textual content: $textual content)
.centered($focusedField, equals: .discipline)
.onAppear {
self.focusedField = .discipline
}
.padding()
.keyboardHeight($keyboardHeight)
.onChange(of: keyboardHeight) {
print (keyboardHeight)
}
}
the proper peak is printed, and it’s 370
In resume I’ve this case:
- The internet hosting app hundreds and it is aware of the proper peak the keyboard module may have.
- The keyboard hundreds and it thinks its peak is the complete display screen.
How do I move the proper peak from the internet hosting app to the keyboard module?
I can consider a posh method utilizing iCloud.
Is there a sane method to try this?
boAt Airdopes 207 TWS Earbuds with 50 hrs Playtime, Quad Mics with ENx Tech, ASAP Charging, IWP Tech, Beast Mode with 50 ms Low Latency, Bluetooth v5.3, USB Type-C Port & IPX5(Bold Blue)
₹899.00 (as of May 14, 2024 14:12 GMT +00:00 - More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)Oneplus Bullets Z2 Bluetooth Wireless in Ear Earphones with Mic, Bombastic Bass - 12.4 mm Drivers, 10 Mins Charge - 20 Hrs Music, 30 Hrs Battery Life, IP55 Dust and Water Resistant (Magico Black)
₹1,499.00 (as of May 14, 2024 14:12 GMT +00:00 - More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)POCO C65 Pastel Green 8GB RAM 256GB ROM
₹7,999.00 (as of May 14, 2024 14:12 GMT +00:00 - More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)iQOO Z9 5G (Graphene Blue, 8GB RAM, 128GB Storage) | Dimensity 7200 5G Processor | Sony IMX882 OIS Camera | 120Hz AMOLED with 1800 nits Local Peak Brightness | 44W Charger in The Box
₹19,999.00 (as of May 14, 2024 14:12 GMT +00:00 - More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)Samsung Original 25W Single Port, Type-C Fast Charger, (Cable not Included), White
₹1,297.00 (as of May 14, 2024 14:12 GMT +00:00 - More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)Ambrane Unbreakable 60W / 3A Fast Charging 1.5m Braided Micro USB Cable for Smartphones, Tablets, Laptops & other Micro USB devices, 480Mbps Data Sync, Quick Charge 3.0 (RCM15, Black)
₹149.00 (as of May 14, 2024 14:12 GMT +00:00 - More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)Oakter Mini UPS for 12V WiFi Router Broadband Modem | Backup Upto 4 Hours | WiFi Router UPS Power Backup During Power Cuts | UPS Broadband Modem | Current Surge & Deep Discharge Protection
₹1,099.00 (as of May 14, 2024 14:12 GMT +00:00 - More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)Portronics My Buddy K Portable Laptop Stand with Adjustable Height, Foldable, OverHeating Protection for Laptops & MacBooks (Grey)
₹498.00 (as of May 14, 2024 14:12 GMT +00:00 - More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)Ambrane Unbreakable 60W Fast Charging 1.5M Braided Type C to Type C Cable for Smartphones, Tablets, Laptops & other Type C devices, PD Technology, 480Mbps Data Sync (RCTT15, Black)
₹159.00 (as of May 14, 2024 14:12 GMT +00:00 - More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)Lapster 24pcs Mix Spiral Charger Spiral Charger Cable Protectors for Wires Data Cable Saver Charging Cord Protective Cable Cover
₹99.00 (as of May 14, 2024 14:12 GMT +00:00 - More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)Auto Amazon Links: No products found.