我正在尝试将 aUITextField放入 aUITableViewCell中。
现在我有两种工作方法。
使用addSubview方法:
UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"textFieldCell"];
UITextField *textFieldView = [[UITextField alloc] initWithFrame:CGRectMake(150, 7, 150, 30)];
[textFieldView setPlaceholder:@"Placeholder"];
[cell addSubview:textFieldView];
使用setAccessoryView方法:
UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"textFieldCell"];
UITextField *textFieldView = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, 150, 30)];
[textFieldView setPlaceholder:@"Placeholder"];
[cell setAccessoryView:textFieldView];
在我看来,setAccessoryView结果更好看,因为对齐是自动完成的。
但我的问题是:可以把 a 放在 aUITextField里面AccessoryView吗?还是有充分的理由为什么我不应该那样做?