iphone keyboard won't appear

Posted by d_CFO on Stack Overflow See other posts from Stack Overflow or by d_CFO
Published on 2010-03-24T22:12:09Z Indexed on 2010/03/24 22:13 UTC
Read the original article Hit count: 144

Filed under:
|

I can click on the field, and it momentarily turns blue, but those events plus makeFirstResponder together do not cause the keyboard to show on a UITextField.

Plain vanilla code follows; I include it so others can discern what is NOT there and therefore what, presumably, with solve the problem.

I put in leading spaces to format this question more like code, but the parser seems to have stripped them, thus leaving left-justified code. Sorry!

UITextFieldDelete, check:

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

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

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

Delegate and source, check.

-(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];
}

Insert UITextField to cell, check.

- (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; } break; } }

Successfully end up where we want to be (?), no check, (and no keyboard!):

- (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;

} break; case 1: // code break; default: // handle otherwise un-handled exception break; } }

Thank you for your insights!

© Stack Overflow or respective owner

Related posts about iphone

Related posts about keyboard