![](/img/trans.png)
[英]Swift Stepper Action that changes UITextField and UILabel within same cell
[英]UILabel and UITextField overlapping in the same cell
在一個UITableViewCell
我有如下的UILabel
和UITextField
:
如您所見, UITextField
右對齊。 在文本字段中寫一些東西之后,它就會重疊。
如何避免這種情況?
這些代碼片段是如何填充單元格的
cell.textLabel.text = R_NAME_CLIENT_NAME;
self->clientNameLabel = cell.textLabel;
[self createTextField:&clientName WithDefaultText:@"none" WithText:@"" InCell:cell IndexPath:indexPath];
- (void) createTextField:(UITextField**)textField WithDefaultText:(NSString*)defaultText WithText:(NSString*)text InCell:(UITableViewCell*)cell IndexPath:(NSIndexPath*)indexPath{
*textField = [[UITextField alloc] initWithFrame:CGRectMake(10, 11, cell.frame.size.width - 20, 20)];
(*textField).font = [UIFont fontWithName:@"Arial-ItalicMT" size:17];
}
可能重復並沒有幫助我。
為兩個元素提供正確的框架:
CGFloat width = 100;
CGFloat height = 25;
myLabel.frame = CGRectMake (0,0, width, height);
CGFloat labelEndX = myLabel.frame.origin.x + myLabel.frame.size.width;
myTextField.frame = CGRectMake(labelEndX , 0, cell.contentView.size.width - labelEndX, height);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.