Table Cell SubView Iteration Not Finding TextField

前端 未结 4 505
面向向阳花
面向向阳花 2021-01-17 07:03

I\'ve created a table where each cell holds both a text label and a text field. I\'m adding the textfields as such [cell addSubview:passwordField]; and from a v

4条回答
  •  情深已故
    2021-01-17 07:48

    You have added your textField on subView of cell.

    [cell addSubview:passwordField];
    

    While you're trying to find it on cell.contentView.
    Add your textField as a subView of cell.Contentview

    [cell.contentView addSubview:passwordField];
    

    And find it in this way -

    for(UIView *view in [cell.contentView subviews])
    {
        if([view isKindOfClass:[UITextfield class]])
        {
           UITextField *textField = (UITextField *)view;
           NSLog(@"%@",textField.text);
        }
    }
    

提交回复
热议问题