3

私は現在、1つのアプリケーションで作業しており、テーブルビューセルにラベルが必要です。ユーザーがそのラベルをタップすると、キーボードにその方法が表示され、誰かが教えてくれます。

ありがとう

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:                       

 (NSIndexPath*)indexPath {
 static NSString *CellIdentifier = @"Cell";
 UITableViewCell *cell = [tableView
 dequeueReusableCellWithIdentifier:CellIdentifier];
  if (cell == nil) {
    cell = [[[UITableViewCell alloc]
             initWithStyle:UITableViewCellStyleValue1
             reuseIdentifier:CellIdentifier]
            autorelease];
  }
 cell.textLabel.text=[Players objectAtIndex:indexPath.row];

 playername=[[UITextField alloc]initWithFrame:CGRectMake(10, 5, 100, 30)];  
 playername.placeholder=@"Player";
 playername.delegate=self;
 playername.keyboardType=UIKeyboardTypeDefault;
 playername.returnKeyType=UIReturnKeyDone;
 [cell.contentView addSubview:playername];


 cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
 return cell;

 }
4

1 に答える 1

1

UITextField または UITextView を使用しないアプリでは奇妙です

ただし、これが必要な場合は、非表示の UITextField または UITextView を作成してキーボードを表示することができます

UITextField *tf = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
[self.view addSubview:tf];
[tf becomeFirstResponder];

入力を処理できるように UITextFieldDelegate を使用します

于 2012-04-19T06:37:15.330 に答える