1

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

在这里,我UItextfieldUIView xib文件中添加了一个,当我单击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;
}
4

3 回答 3

2

您可以通过以下任何一种方式执行此操作

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
于 2016-02-11T06:25:53.447 回答
0

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

执行以下操作:

UIView *HeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, CGrectGetWidth(tableView.bounds), 44.0f)];
于 2016-02-11T06:28:21.230 回答
-1

选择 textView 并检查属性检查器。可能是这种情况!

在此处输入图像描述

于 2016-02-11T06:31:43.343 回答