我已经构建了一个带有两个单元格的自定义 UITableView。在一个单元格中,我添加了一个 UIImageView,在另一个单元格中添加了一个 UILabel。当我使用 UILabel 单击单元格时,会弹出一个不需要的键盘,并带有闪烁的光标。我已检查以确保我没有使用重复的重用标识符。为什么会这样?我认为 UILabels 不会调用键盘。我怎样才能摆脱这个?有没有办法通过委托方法访问单元格,例如
- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath
???
在此先感谢您的帮助。这是我的代码:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:qRViewCellIdentifier];
NSUInteger row = [indexPath row];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:qRViewCellIdentifier] autorelease];
if (row == kQRRowIndex)
{
CGRect imageRect = CGRectMake(10,10.0,255.0,255.0);
UIImageView *qRImageView = [[[UIImageView alloc] initWithFrame:imageRect] autorelease];
qRImageView.tag = row;
[cell.contentView addSubview:qRImageView];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
else
{
CGRect labelRect = CGRectMake(10,10.0,255.0,25.0);
UILabel *fastPayLabel = [[UITextField alloc] initWithFrame:labelRect];
fastPayLabel.tag = row;
[cell.contentView addSubview:fastPayLabel];
}
}
if (row == kQRRowIndex)
{
UIImageView *qRImageView = (UIImageView *)[cell viewWithTag:kQRRowIndex];
qRImageView.image = [[UserManager sharedUserManager] qRImage];
}
else
{
NSString *message = [NSString stringWithString:@"Enable Fast Pay"];
UILabel *fastPayLabel = (UILabel *)[cell viewWithTag:kFastPayRowIndex];
fastPayLabel.textAlignment = UITextAlignmentCenter;
fastPayLabel.text = message;
fastPayLabel.font = [UIFont boldSystemFontOfSize:20];
}
return cell;
}