Ios UITextField上下文菜单(剪切、粘贴等)未显示

Ios UITextField上下文菜单(剪切、粘贴等)未显示,ios,swift,uitextfield,Ios,Swift,Uitextfield,当我长按或双击文本字段时,带有标准文本操作(剪切、粘贴、复制、查找)的上下文菜单不显示。相反,这两个操作似乎都选择了文本字段的内容,并允许我将所选内容拖到其他位置 我正在使用以下自定义UITextField子类: 类BMTextField:UITextField{ 必需的初始化(占位符:字符串?=nil,文本:字符串?=nil){ super.init(帧:CGRect.zero) font=UIFont(名称:Fonts.Light,大小:18) textColor=Colors.Gray51

当我长按或双击文本字段时,带有标准文本操作(剪切、粘贴、复制、查找)的上下文菜单不显示。相反,这两个操作似乎都选择了文本字段的内容,并允许我将所选内容拖到其他位置

我正在使用以下自定义
UITextField
子类:

类BMTextField:UITextField{
必需的初始化(占位符:字符串?=nil,文本:字符串?=nil){
super.init(帧:CGRect.zero)
font=UIFont(名称:Fonts.Light,大小:18)
textColor=Colors.Gray51
layer.borderColor=Colors.gray51 transparent.cgColor
layer.borderWidth=2
layer.cornerRadius=0
self.placeholder=占位符
self.text=文本
}
必需初始化?(编码器:NSCoder){
fatalError(“初始化(编码者:)尚未实现”)
}
让padding=UIEdgeInsets(顶部:0,左侧:16,底部:0,右侧:0);
重写func占位符rect(forBounds-bounds:CGRect)->CGRect{
返回bounds.inset(by:padding)
}
重写func textRect(forBounds bounds:CGRect)->CGRect{
返回bounds.inset(by:padding)
}
重写func editingRect(forBounds-bounds:CGRect)->CGRect{
返回bounds.inset(by:padding)
}
}
下面是我如何将其添加到superview(使用SnapKit)中的:

lastNameTextField.textContentType=.familyName
lastNameTextField.autocorrectionType=.yes
showingSuperview.addSubview(lastNameTextField)
lastNameTextField.snp.makeConstraints{
达成协议
make.height.equalTo(M.standardControlHeight)
make.top.equalTo(firstNameTextField.snp.bottom).offset(S.thirtyTwo)
make.left.right.equalToSuperview()
}        

我试着用一个文本字段创建一个全新的项目,在那里,一切都很顺利。

无法复制。原因可能在别处。尝试用BMTextField创建一个最小的全新项目。另外,请记住,剪贴板上需要有某些内容才能显示“粘贴”菜单,并且需要有一个选项才能显示“复制”菜单。我尝试过了,但仍然不起作用:/