клавиатура iphone не появится - PullRequest
0 голосов
/ 25 марта 2010

Я могу щелкнуть поле, и оно на мгновение становится синим, но эти события вместе с makeFirstResponder не приводят к отображению клавиатуры в UITextField.

следует простой ванильный код; Я включил это, чтобы другие могли различить, что НЕ там, и, следовательно, что, по-видимому, решить проблему.

Я поставил начальные пробелы для форматирования этого вопроса, больше похожего на код, но синтаксический анализатор, похоже, удалил их, оставив код, выровненный по левому краю. Извините!

UITextFieldDelete, проверьте:

@interface RevenueViewController : UIViewController <UITableViewDelegate, UITableViewDataSource, UITextFieldDelegate> {

UILabel * sgmntdControlLabel; UISegmentedControl * sgmntdControl; UITableView * theTableView; } * +1010 *

@property(nonatomic,retain) UISegmentedControl *sgmntdControl;
@property(nonatomic,retain) UILabel *sgmntdControlLabel;

Делегат и источник, проверьте.

-(void)loadView;
  // code
  CGRect frameTable = CGRectMake(10,0,300,260);
  theTableView = [[UITableView alloc] initWithFrame:frameTable style:UITableViewStyleGrouped];
  [theTableView setDelegate:self];
  [theTableView setDataSource:self];
  // code
  [self.view addSubview:theTableView];
  [super viewDidLoad];
}

Вставьте UITextField в ячейку, проверьте.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSInteger sectionNmbr = [indexPath section];
NSInteger rowNmbr = [indexPath row];
NSLog(@"cellForRowAtIndexPath=%d, %d",sectionNmbr,rowNmbr);
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
// Configure the cell. 
switch (sectionNmbr) {
case 0: 
   if (rowNmbr == 0) {
   cell.tag = 1;
   cell.textLabel.text = @"Label for sctn 0, row 0";
   UITextField *tf = [[UITextField alloc] init];
   tf.keyboardType = UIKeyboardTypeNumberPad;
   tf.returnKeyType = UIReturnKeyDone;
   tf.delegate = self;
   [cell.contentView addSubview:tf];
  }
if (rowNmbr == 1) {
cell.tag = 2;
cell.textLabel.text = @"Label for sctn 0, row 1";
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;

} перерыв; } }

Успешно закончить, где мы хотим быть (?), Без проверки, (и без клавиатуры!):

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(@"didSelectRowAtIndexPath");
switch (indexPath.section) {
case 0: 
NSLog(@"  section=0, rowNmbr=%d",indexPath.row);
switch (indexPath.row) {
case 0:
UITableViewCell *cellSelected = [tableView cellForRowAtIndexPath: indexPath];
UITextField *textField = [[cellSelected.contentView subviews] objectAtIndex: 0];
[ textField setEnabled: YES ];
[textField becomeFirstResponder];
// here is where keyboard will appear?
[tableView deselectRowAtIndexPath: indexPath animated: NO];
break;
case 1:
// code
break;
default:
break;

} перерыв; Случай 1: // код перерыв; дефолт: // обрабатывать в противном случае необработанное исключение перерыв; } }

Спасибо за ваши идеи!

1 Ответ

0 голосов
/ 25 марта 2010

Вы уверены, что

[[cellSelected.contentView subviews] objectAtIndex: 0];

возвращает то, что вы ожидаете? Попробуйте проверить это с помощью отладчика

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...