I want to create a view just like iphone's contact edit view.
I have A UITextField inside UITableViewCell.
I want to focus on the UITextField inside the UITableViewCell, and make the keyboard slides with the view from the right.
now its appearing without sliding, but the view is.
Here is the code:
Code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *TrackEditCellIdentifer = @"TrackEditCellIdentifer";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:TrackEditCellIdentifer];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:TrackEditCellIdentifer] autorelease];
UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(10, 14, 200, 25)];
textField.clearsOnBeginEditing = NO;
textField.returnKeyType = UIReturnKeyDone;
textField.font = [UIFont boldSystemFontOfSize:14];
textField.enabled = YES;
textField.tag = kTextFieldTag;
textField.textColor = [UIColor blackColor];
[textField becomeFirstResponder];
[cell.contentView addSubview:textField];
[textField release];
}
// Set up the cell...
//NSUInteger row = [indexPath row];
// determine the textfield
UITextField *txtfield = (UITextField *)[cell viewWithTag:kTextFieldTag];
txtfield.text = self.textFieldString;
if ([self textType] == kNameKey)
[txtfield setPlaceholder:@"Name"];
if ([self textType] == kTagKey)
[txtfield setPlaceholder:@"Tags"];
[self setCurrentTextField:txtfield];
return cell;
}
i have tried calling this in viewdidload and viewdidappear, but the results are the same.
Code:
- (void)viewDidLoad {
[currentTextField becomeFirstResponder];
[super viewDidLoad];
}
- (void)viewDidAppear:(BOOL)animated {
[currentTextField becomeFirstResponder];
[super viewWillAppear:animated];
}