I have built a custom UITableView with two cells. In one cell I have added a UIImageView, in another a UILabel. when I click on the cell with the UILabel an unwanted keyboard pops up with a blinking cursor. I have checked to make sure I am not using a duplicate reuse identifier. Why is this happening? I thought UILabels don't call the keyboard. How can I get rid of this? Is there a way to access the cell through a delegate method like
- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath
???
Thanks in advance for your help. Here is my code:
- (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;
}
Man, you have a typo here: UILabel *fastPayLabel = [[UITextField alloc] initWithFrame:labelRect];
.
Instead of allocating UILabel object, you're actually allocating UITextField... =)