我以编程方式在uitableviewcontroller内创建了uitextview,但我无法编辑textview。下面就以我的表布局的概述:在UITableViewController单元格内创建可编辑的UITextView
ROW1:的UILabel
行2:不可编辑的UITextView
ROW3:的UILabel
ROW4:可编辑的UITextView
这里的我在做什么:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UILabel *label = nil;
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if(indexPath.row%2==0)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, cell.frame.size.width, 50)];
[label setBackgroundColor:[self.cellBackgroundColor objectAtIndex:indexPath.row]];
[label setText:[self.celltitle objectAtIndex:indexPath.row]];
label.font=[UIFont fontWithName:[self.cellFontName objectAtIndex:indexPath.row] size:[[self.cellFontSize objectAtIndex:indexPath.row] integerValue]];
label.textAlignment = NSTextAlignmentLeft;
[[cell contentView] addSubview:label];
}
else{
UITextView *messageBox= [[UITextView alloc] initWithFrame:CGRectMake(0, 0, cell.frame.size.width, 150)];
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
cell.userInteractionEnabled=YES;
if(indexPath.row==3)
{
[messageBox setEditable:YES];
[messageBox setUserInteractionEnabled:YES];
messageBox.delegate=self;
messageBox.editable=YES;
}
[cell.contentView addSubview: messageBox];
}
return cell;}
我也设置了textviewdelegat在头文件中的文本和textviews应该是方法,但row4的textview仍然是不可编辑的...任何帮助?
做委托方法应对? – Luke 2013-02-14 13:16:08
没有..委托方法没有响应.. – Shaunak 2013-02-14 13:19:25
你有.h正确的链接,你添加了? –
2013-02-14 13:23:43