Why Does The Messagekit ('Jsqmessagesviewcontroller' Replacement) Input Field Disappears When Vc Segues From-Right

Text Field/Send button disappears on keyboard pop on JSQMessagesViewController

Solved this....I simply needed to call super in my viewWillAppear:

override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(true)
}

How to limit user text input and disable send button in JSQMessagesViewController

You should not remove the button from the bar but instead just disable it. I would first suggest setting a disabled state for the button with something like this.

let sendButton = UIButton(frame: CGRect(x: 0, y: 0, width: 80, height: 35)) //You can change these values to fit your needs
sendButton.setTitle("Send", forState: .Normal)
sendButton.setTitleColor(UIColor.grayColor(), forState: .Disabled)
sendButton.setTitleColor(UIColor.whiteColor(), forState: .Normal)
sendButton.contentMode = .Center
self.inputToolbar?.contentView?.rightBarButtonItem = sendButton

Then you want to set the userInteractionEnabled property on that button based on the length of the string in the input field. We can accomplish this by setting an observer on that.

First get a reference to the inputField.
let inputField = self.inputToolbar.contentView.inputView
Then set up a observer on that field and change the sendButtons state.

NSNotificationCenter.defaultCenter().addObserverForName(UITextFieldTextDidChangeNotification, object: inputField, queue: NSOperationQueue.mainQueue()) { (notification) in
let text = self.inputField.text

You do not need parentheses () around if statements.
Also I would swap your logic around

if text.characters.count >= 10 && text.characters.count <= 140 {
if text == self.verifyPasswordField.text {
self.sendButton.enabled = true
} else {
self.sendButton.enabled = false
}
}

if you want to be a swift ninja you can do shorthand for this with.

self.sendButton.enabled = (text.characters.count >= 10 && text.characters.count <= 140)

just throw that in a function and make sure you call it and you should be good to go. The Button should update its color if the input text does not meet the criteria. But you also may want to tell your users that, that is the reason the button is disabled but that is just my opinion. I hope this helped let me know if you have any more questions. /p>

jsqmessageviewcontroller ios11 toolbar

Guys I have figured it out! Just put the following code in the JSQMessagesInputToolbar.m. It seems that the inputtoolbar is placed in its own window, you need to access its window separately.

-(void) didMoveToWindow{
[super didMoveToWindow];
if (@available(iOS 11.0, *)) {
[[self bottomAnchor] constraintLessThanOrEqualToSystemSpacingBelowAnchor:self.window.safeAreaLayoutGuide.bottomAnchor multiplier:1.0].active = YES;
}
}


Related Topics



Leave a reply



Submit