设置为另一个UITextField的inputAccessoryView时,UITextField Height不会更改
var textF2 = UITextField() textF2.borderStyle = UITextBorderStyle.None textF2.frame.size = CGSizeMake(200, 200) textF2.text = self.textField.text textF2.backgroundColor = UIColor.whiteColor() self.textField.inputAccessoryView = textF2
textF2的高度拒绝正确设置,至less在外观上。
println(textF2.frame.size.height)
给我200新的价值,但它并没有出现在模拟器中。
inputAccessoryView是否会导致与设置高度有关的问题?
var textF2 = UITextField() textF2.borderStyle = UITextBorderStyle.None textF2.frame = CGRectMake(50, 50, 200, 200) textF2.text = self.textField.text textF2.backgroundColor = UIColor.whiteColor() self.view.addSubview(textF2)
事实上给我适当的外观,所以
self.textField.inputAccessoryView = textF2
是问题。 有人知道为什么吗?
inputAccessoryView
只是一个正常的UIView
,所以要正确定位,你应该始终设置frame
,只设置大小将没有任何影响。
另外,请记住,在对象成为第一响应者之后,对inputAccessoryView
任何更改inputAccessoryView
都应该对inputAccessoryView
进行调用,否则它们将不起作用。