簡體   English   中英

UILabel和UITextField在同一單元格中重疊

[英]UILabel and UITextField overlapping in the same cell

在一個UITableViewCell我有如下的UILabelUITextField

http://i.stack.imgur.com/ZsawF.png

如您所見, 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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM