In xcode14 + ios16, the uiview is not visible above the keyboard - ios16

I am developing a chat app. I tested the app on xcode14, ios16. If you click the emoticon button while the keyboard is exposed to write a chat text, the uiview should be exposed on the virtual keyboard, but it is not visible. In xcode13 it works fine. Is there any way?
//not work!!!!
self.emoticonView!.layer.zPosition = CGFloat(MAXFLOAT) let windowCount = UIApplication.shared.windows.count UIApplication.shared.windows[windowCount-1].addSubview(self.emoticonView!)

Related

Hiding IOS keyboard suggestion bar appearing above custom keyboard

I am developing a custom keyboard extension app, but apple keyboard native autocorrection and suggestion does not function with my app. The native autocorrection and suggestion bar is empty and appears persistently above my custom keyboard. I am trying to hide it to create my own with my suggestion list.
The problem is I did not find the way to hide the native suggestion bar.
UITextInputAssistantItem *item = [textInput.textInputView inputAssistantItem];
item.leadingBarButtonGroups = #[];
item.trailingBarButtonGroups = #[];
does not work because my custom keyboard does not use a textInput. My custom keyboard works with external text input fields like for example Safari search field using self.textDocumentProxy
Also
self.inputAssistantItem.leadingBarButtonGroups = #[];
self.inputAssistantItem.trailingBarButtonGroups = #[];
does not work.
Any help?
Thank you.

Custom keyboard on UITextView shows apple keyboard first then switches to the custom keyboard

Short video of what happens when tapping on a textView:
https://www.youtube.com/watch?v=LG_r3iDJKiM
I'm trying to show my custom keyboard on a UITextView from the textViewDidBeginEditing function, The custom keyboard has been tested on UITextFields and is working as intended. Now I'm trying to get the same keyboard to work with UITextViews.
When opening the app for the first time, and tapping on a textView the first time will have this behavior, then when we tap on other textViews the custom keyboard is there directly as intended.
the Current code in my TextViewDidBeginEditing, I tried changing the order of the last 4 lines but with no success:
public func textViewDidBeginEditing(_ textView: UITextView) {
keyboard = Keyboard.sharedInstance.keyboardWithType(availableKeyboards.numbers.rawValue, returnKey:textView.returnKeyType, isSecure: false,decimalSeparator:self.decimalSeparatorCharacter, responderClass: self)
inputView.keyboardAppearance = .dark
inputView.hideAssistantBar()
inputView.inputView = keyboard
inputView.reloadInputViews()
}
This will result in the video above, I tried some other ways but no success yet:
Setting a empty UIView as the inputView, this will still result in the apple keyboard shortly appearing
let view:UIView = UIView()
textView.inputView = view
also tried doing reloadInputViews but that doesn't work either:
textView.reloadInputViews()
also tried running it all on the main tread with
DispatchQueue.main.async { }
but no success, I cannot understand why even setting a UIView() as the inputView will still shortly show the apple keyboard. Any help in the right direction would be greatly appreciated!
Thanks in advance!

backBarButtonItem becomes visible on iOS 10 when titleView has constraints

Having a very weird behavior on iOS 10. Assume you have an empty app, created with a Master-Detail Application template. Place any UIView as a titleView in navigationBar for detail viewcontroller. Place any UIView to the right bar button items.
Then, write that code to configureView method:
if let item = self.splitViewController?.displayModeButtonItem {
self.navigationItem.leftBarButtonItem = item
self.navigationItem.leftItemsSupplementBackButton = true
}
Then configure splitviewcontroller preferredDisplayMode = .allVisible, so the displayModeButtonItem could appear.
On iOS 9 and lower this results in a standard behavior: the detail viewcontroller displays displayModeButtonItem expand button on a left side.
When user taps it, the icon transforms to an arrow. Tapping an arrow reverses button state.
On iOS 10 displayModeButtonItem displays as expand button, but if user taps it, it disappears.
Meanwhile, the button is still there and a user can tap it one more time. After that, displayModeButtonItem appears again with expand icon and backButtonItem icon as well. Just like it appears when we push another viewcontroller onto detail's navigationcontroller:
But in that case both of icons acts as displayModeButtonItem.
Is this an iOS bug, or a misconfig? What can I do to get normal button behavior?
Edit: I found out, that everything works as expected, if a titleView (of rightBarButtonItem's view) does not contain any constraints on it's child views. Filed a radar on this.
Edit 2: Some controls (like UIImageView) may implicitly add NSContentSizeLayoutConstraint, so, to prevent this behavior (and prevent the bug above), subclass it and override intrinsicContentSize method like this:
private class NoConstraintsUIImageView: UIImageView {
private override func intrinsicContentSize() -> CGSize {
// prevent implicit NSContentSizeLayoutConstraint adding in updateConstraints
return CGSize(width: UIViewNoIntrinsicMetric, height: UIViewNoIntrinsicMetric)
}
}

UITextView doesn't switch input toolbar to custom keyboard

iOS9 Xcode7 beta6: I'm trying to switch between keyboards (custom/default) for UITextView by using reloadInputViews(). Changing UIKeyboardType and UIKeyboardAppearance by calling reloadInputViews() works perfectly. Also following code works well under iOS8.
This implies that textView is already a first responder:
private func showCustomKeyboard() {
textView.inputView = customKeyboardView
textView.reloadInputViews()
}
private func showDefaultKeyboard() {
textView.inputView = nil
textView.reloadInputViews()
}
Things like the following have made no effect and also they look like overkill:
textView.inputView.resignFirstResponder()
textView.inputView.becomeFirstResponder()
textView.inputView = customKeyboardView
textView.reloadInputViews()
I found a couple of related questions on SO but no one of them doesn't have to do with iOS9 and as I said before it does work in iOS8.
Have anyone come across this bug?
Did you try to change the order? Because you dismiss and after that show a keyboard again. Does it make sense?:
textView?.inputView.resignFirstResponder() // dismiss keyboard
textView?.inputView.becomeFirstResponder() // show keyboard
textView?.inputView = customKeyboardView // reassign new keyboard
textView?.reloadInputViews() // reload keyboard
Try:
textView?.inputView.resignFirstResponder() // dismiss keyboard
textView?.inputView = customKeyboardView // reassign new keyboard
textView?.reloadInputViews() // reload keyboard
textView?.inputView.becomeFirstResponder() // show keyboard
The bug was related to a simulator with iOS9 on the board and eventually has been fixed with unchecking Keyboard -> Connect -> Hardware Keyboard.

Entered text not showing in UITextView

I have an app i'm trying to port over to iOS 7. As there are no longer any textfields in iOS 7 UIAlertViews. (See here) I have to resort to using 2 UIViews managed by 1 ViewController. I didn't use nib files and just program the UI from code.
When the app is started, the second UIView is stacked on top of the first one, it has a UITextField that takes in a user input. This code works in iOS 7 but does not work on iOS 6 devices.
In an iOS 6 device, when I tap on the textfield in the 2nd UIView, the keyboard appears. However when I enter something into the textfield, no characters appear. I even tried to NSLog the characters entered by the keyboard and got NULL which means no text is entered!
The code is as follows for the primary ViewController:
//View1 : UIView
View1 *aView1;
[aView1 initWithFrame:CGRectMake(20,40,280,200) title:promptMsg]
[self.view addSubview:aView1];
Inside the View1.m:
(id)initWithFrame:(CGRect) aRect title:(NSString*) promptStr{
self = [super initWithFrame:aRect];
UITextField *userField = [[UITextField alloc] initWithFrame:CGRectMake(x,y,a,b)];
[self addSubview:userField];
Does any know what has changed in iOS 7 that 'allows' this behaviour? IS it a bug in iOS 7 or the SDK?
The problem is in your code i did not see any text you are setting, you are just allocating for example refer below:-
(id)initWithFrame:(CGRect) aRect title:(NSString*) promptStr{
self = [super initWithFrame:aRect];
UITextField *userField = [[UITextField alloc] initWithFrame:CGRectMake(x,y,a,b)];
userField.text=#"yourText"; // here setting the text
[self addSubview:userField];
}

Resources