0
我正在iOS下工作,我添加了幾個單元格,每個單元格都有一個UITextField作爲子視圖添加。摘錄:UITextField在編輯UITableViewCell時不會自動調整大小
UITextField *t = [[UITextField alloc] initWithFrame:CGRectMake(20.0, 5.0, 220.0, 20.0)];
// here I set properties for t ...
t.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleWidth;
[cell addSubview:t];
cell.autoresizeSubviews = YES;
// if needed, I set the UIImageView for the cell
if (...) {
cell.imageView.image = [UIImage imageNamed:@"myimage.png"];
t.frame = CGRectOffset(text.frame, 33, 0);
}
[t release];
會發生什麼?當我進入tabel的編輯模式時,我期望每個單元格都將調整大小以使紅色減號可見,並且UITextField將向右移動以保持與單元格本身對齊,如同其他組件。但是這不會發生。
而且,我試圖改變使用UIViewAutoresizingFlexibleLeftMargin
,UIViewAutoresizingFlexibleRightMargin
和UIViewAutoresizingFlexibleWidth
各種組合autoresizingMask
PARAM,但沒有成功。
我在這裏做錯了什麼?我應該改變將文本字段添加爲子視圖的方式嗎?
謝謝!
我沒有嘗試只是......我嘗試添加到'textLabel',到'detailTextLabel' ...爽,謝謝您! – marzapower 2011-05-24 12:41:09