【发布时间】:2014-02-01 01:13:19
【问题描述】:
我想知道如何获取我的自定义 UITableViewCell 的实例,以便我可以将 UITextfield 设置为第一响应者
这就是我在 cellForRowAtIndexPath 中设置自定义单元格的方式
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[CustomFinishingCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
但是,当我尝试在 didSelectRowAtIndexPath 中设置所选单元格的实例时,出现错误
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
CustomFinishingCell *cell = [tableView cellForRowAtIndexPath:indexPath]; // error
[cell.widthTexField becomeFirstResponder];
这是我收到的错误
使用“UITableViewCell *”类型的表达式初始化“CustomFinishingCell *”的不兼容指针类型
【问题讨论】:
-
编译器错误,还是运行时错误?
标签: ios uitableview uitextfield