UITableView
ラベル付きのフィールドをレイアウトするために を使用していますが、奇妙な動作が発生しています。TextFieldView
を実装し、とをその にUITableViewCell
追加するというクラスがあります。その後、table-delegate を介してテーブルのセルとして追加されます。、、、を使用します。UITextField
UILabel
subviews
TextFieldView
cellForRowAtIndexPath
heightForRowAtIndexPath
numberOfRowsInSection
didSelectRowAtIndexPath
問題は、テーブルを最初にロードしたとき、すべてのセルの高さが 44 であることです。しかし、テーブルがロードされると、最初と最後のセル フレームの高さが 45 に設定されますtable.beginUpdates/table.endUpdates
。テキスト更新) 最初と最後のセルの高さが +1 ずつ増加します。
begin/endUpdates と呼ぶ理由はUITextView
、コンテンツを変更すると展開される もあるからです。UITextView
ただし、これが「バグ」と関係があるかどうかを確認するために削除しましたが、そうではありません。
誰かが同様の問題を抱えていることを願っています-または私たちの脳のおならを見つけることができます! - 私たちは皆、アイデアがありません:-)
を初期化する方法は次のUITableViewCell
とおりです。
class TextFieldView < UITableViewCell
....
def init()
super.initWithStyle(UITableViewCellStyleDefault, reuseIdentifier: nil)
self.selectionStyle = UITableViewCellSelectionStyleNone
self.styleClass = 'control'
@focus = UIImageView.alloc.initWithImage(UIImage.imageNamed('focus.png'))
frame = self.frame
@focus.frame = [[frame.size.width - 13, 8], [13, 28]]
@focus.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin
@focus.hidden = true
self.contentView.addSubview(@focus)
size = self.frame.size # 44 x 320
self.styleClass = 'control text-field'
@label = self.create_label([[10, 10], [140, 24]])
self.contentView.addSubview(@label)
@text_field = UITextField.alloc.initWithFrame([[160, 11], [size.width - 160 - 20, 24]])
@text_field.adjustsFontSizeToFitWidth = true
@text_field.minimumFontSize = 13
@text_field.autoresizingMask = UIViewAutoresizingFlexibleWidth
@text_field.borderStyle = UITextBorderStyleNone
@text_field.backgroundColor = UIColor.redColor
@text_field.font = UIFont.boldSystemFontOfSize(17)
@text_field.styleClass = 'control'
self.contentView.addSubview(@text_field)
#@text_field.delegate = is handle by the view controller
self
end