当我们点击它时,UItextfield 不可编辑

UItextfield not editable when we tapped on it

嗨,我是 ios 的新手,我在我的应用程序中添加了 UITableList,在这里我在 tableList HeaderView 上添加了 UIView xib 文件]

我在 UIView xib 文件上添加了一个 UItextfield,当我单击那个 textfield 它不可编辑时,我的意思是 click action not working 请帮忙我一个

我的代码:-

-(UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{

    UIView *HeaderView = [[UIView alloc] init];
    HeaderView.backgroundColor = [UIColor clearColor];

    header = [[EscortHederView alloc] initWithFrame:CGRectMake(HeaderView.frame.origin.x, HeaderView.frame.origin.y, HeaderView.frame.size.width, HeaderView.frame.size.height)];
    [HeaderView addSubview:header];

    header.coridersTextfield.delegate = self;
    header.coridersTextfield.userInteractionEnabled = YES;

    return HeaderView;
}

您可以通过以下任一方式进行

header.coridersTextfield.editable = YES;
// or 

 header.coridersTextfield.userInteractionEnabled = YES;

// or 

  header.coridersTextfield. enabled = YES;

或使用委托方法

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
return YES;
}

更新

UIView *HeaderView = [[UIView alloc] init];
HeaderView.frame = CGRectMake(x,y, width, height); // customize frame and set the Height based on your Subviews Height

HeaderView的边界是(x:0, y:0, width:0, height:0)

执行以下操作:

UIView *HeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, CGrectGetWidth(tableView.bounds), 44.0f)];

Select textView 并检查 属性 检查器。可能是这样!