Мигающий курсор появляется, когда я нажимаю на UILabel в сочетании с появлением клавиатуры - PullRequest
0 голосов
/ 17 июня 2011

Я построил пользовательский 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;
}

1 Ответ

3 голосов
/ 26 июня 2011

Чувак, у тебя тут опечатка: UILabel *fastPayLabel = [[UITextField alloc] initWithFrame:labelRect];.Вместо выделения объекта UILabel вы фактически выделяете UITextField ... =)

...