こんにちは私はプログラムでビューを作成しました。ラベルとテキストフィールドを追加しました。しかし、テキストフィールドをタップすると、テキストフィールドが機能しません。デリゲートメソッドを呼び出すことさえありません。これで助けてください。UITextFieldが応答しない
ループのために、私は、テキストフィールドのプロパティをretrunする//
方法をテキストフィールドを持つビューを作成し、lable
func createTextFieldForDropDown(entity:ListingCategoryFeaturesEntity,ival:Int,ypos:CGFloat) -> UIView
{
var posY = ypos
var posX = CGFloat(0)
let width = (SCREEN_WIDTH/2)-15
var height = CGFloat(40)
let viewRadio = UIView()
viewRadio.frame = CGRectMake(posX, posY, width, height)
viewRadio.backgroundColor = UIColor.greenColor()
height = 40
posY = 0
let lblTitle = UILabel()
lblTitle.frame = CGRectMake(posX, posY, width, height)
lblTitle.text = entity.strDisplayName
lblTitle.backgroundColor = UIColor.redColor()
lblTitle.font = GRAPHICS.FONT_REGULAR(16)
viewRadio.addSubview(lblTitle)
let tag = 9000
posX = lblTitle.frame.maxX+10
var textField = UITextField()
textField.frame = CGRectMake(posX, posY, width, height)
textField = returnTextFieldsProperties(textField, placeHolderText: "", tagValue: tag+ival)
textField.backgroundColor = UIColor.blueColor()
textField.becomeFirstResponder()
viewRadio.addSubview(textField)
return viewRadio
}
する//
widgetsView.addSubview(createTextFieldForDropDown(entity,ival:i,ypos: posY))
方法をテキストフィールドを作成するためのこの戻りメソッドを呼び出しています
func returnTextFieldsProperties(textField : UITextField ,placeHolderText : String ,tagValue : Int) -> UITextField
{
textField.attributedPlaceholder = NSAttributedString(string:placeHolderText,
attributes:[NSForegroundColorAttributeName: UIColorFromRGB(colorLightGray, alpha: 1.0)])
textField.font = GRAPHICS.FONT_REGULAR(14)
textField.textAlignment = NSTextAlignment.Left
textField.textColor = UIColor.blackColor()
textField.delegate = self
textField.userInteractionEnabled = true
textField.returnKeyType = UIReturnKeyType.Next
let view_left = UIView()
view_left.frame = CGRectMake(20,0,10,textField.frameHeight)
textField.leftView = view_left
textField.leftViewMode = UITextFieldViewMode.Always
textField.borderStyle = UITextBorderStyle.RoundedRect
textField.backgroundColor = UIColor.clearColor()
textField.autocorrectionType = .No
textField.tag = tagValue
return textField
}
:に
:
変更:ラベルとのTextViewの両方を保持するのに十分な
viewRadio
が広いことを確認します。しかし、私は動的にすべてを作成する必要があります。これについて助けてください。 –'viewRadio.userInteractionEnabled = true'を設定してみてください。 – vacawama
いいえ動作しません。 –