What is troubling me is the order in which modules are called regarding keystrokes.
In TextView input,
(1) @objc showKeyboard
(2)textViewdidbeginEditing
is referred to in the order shown in .
I would like to check the input area in (2) and specify a numeric keyboard or mail keyboard, but the showKeyboard will be called first, so it will not work properly.
TextView is configured as a custom cell, so it has the following modules:
Is there any way to change the order of being called?
By the way, I remember that using textField was the opposite of the above.
import UIKit
protocol Cell_MultiLineDelegate{
functextViewDidEndEditing(textCell:Cell_MultiLine, value:NSString) - >()
functextViewDidBeginEditing(textCell:Cell_MultiLine, value:NSString) - >()
}
class Cell_MultiLine:UICollectionViewCell, UITextViewDelegate{
@IBOutlet weak var leading —NSLayoutConstraint!
@IBOutlet weak var training:NSLayoutConstraint!
@IBOutlet peak:NSLayoutConstraint!
@IBOutlet weak varbottom:NSLayoutConstraint!
@IBOutlet weak var backView: UIView!
@IBOutlet weak var beforeView: UIView!
@IBOutlet weak var contents:UITextView!
// @IBOutlet weak var contents: UITextField!
varcurrentIndexPath —IndexPath!
vardelegate —Cell_MultiLineDelegate!=nil
var currentComment: String!
var fixedComment: String!
override funcawakeFromNib(){
super.awakeFromNib()
// initialization code
self.contents.delegate=self
}
functextView(_textView:UITextView, shouldChangeTextInrange:NSRange, replacementTexttext:String) - >Bool{
if currentIndexPath.row>6 {// Except for the bottom multi-line input area = Special note area
if text == "\n" {
textView.resignFirstResponder()
self.delegate.textViewDidEndEditing (textCell:self, value:contents.text!as NSSstring)
return false
}
}
return true
}
/*
internal func textFieldShouldReturn(_textField:UITextField) - >Bool{
textField.resignFirstResponder()
return true
}
*/
internal func textViewDidEndEditing(_textView:UITextView){
self.delegate.textViewDidEndEditing (textCell:self, value:contents.text!as NSSstring)
}
internal func textViewDidBeginEditing(_textView:UITextView){
self.delegate.textViewDidBeginEditing (textCell:self, value:contents.text!as NSSstring)
}
}
// Vertical Centralization
extension UITextView {
funcenterVerticalText(){
self.textAlignment=.left
letfitSize = CGSize (width: bound.width, height: CGFloat.greatestFiniteMagnitude)
let size = sizeThatFits(fitSize)
let calculate=(bound.size.height-size.height*zoomScale)/2
let offset=max(1,calculate)
contentOffset.y=-offset
}
}
textView
DidBeginEditing
of UITextViewDelegate
is apparently running after the keyboard is displayed.So, why don't you use textViewShouldBeginEditing
?
functextViewShouldBeginEditing(_textView:UITextView)->Bool{
textView.keyboardType=.decimalPad
return true
}
After checking here, I was able to see the numeric keypad with this Delete.
I don't think you're worried about such a simple thing, but just for your information.
596 GDB gets version error when attempting to debug with the Presense SDK (IDE)
606 Uncaught (inpromise) Error on Electron: An object could not be cloned
884 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
572 Understanding How to Configure Google API Key
567 Who developed the "avformat-59.dll" that comes with FFmpeg?
© 2024 OneMinuteCode. All rights reserved.