首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

在UITableViewCell的UITextField中,点 return时,光标移到上一个UITextField

2012-07-02 
在UITableViewCell的UITextField中,点 return时,光标移到下一个UITextField?- (IBAction)textFieldDone:(i

在UITableViewCell的UITextField中,点 return时,光标移到下一个UITextField

?

- (IBAction)textFieldDone:(id)sender {    //[sender resignFirstResponder];    UITableViewCell *cell = (UITableViewCell *)[[sender superview] superview];//sender是文本字段,它是表单元视图的内容视图的一个子视图,[cell.contentView addSubview: textField];    UITableView *table = (UITableView *)[cell superview];    NSIndexPath *textFieldIndexPath = [table indexPathForCell:cell];    NSUInteger row = [textFieldIndexPath row];    row++;    if (row >= kNumberOfEditableRows) {        row = 0;    }    NSIndexPath *newPath = [NSIndexPath indexPathForRow:row inSection:0];    UITableViewCell *nextCell = [self.tableView cellForRowAtIndexPath:newPath];    UITextField *nextField = nil;    for (UIView *oneView in nextCell.contentView.subviews) {        if ([oneView isMemberOfClass:[UITextField class]]) {            nextField = (UITextField *)oneView;        }    }    [nextField becomeFirstResponder];}

?

UITextField *textField = [[UITextField alloc] initWithFrame: CGRectMake(90, 12, 200, 25)];        textField.clearsOnBeginEditing = NO;//鼠标点上时,不清空        [textField setDelegate: self];        //textField.returnKeyType = UIReturnKeyDone;        [textField addTarget:self action:@selector(textFieldDone:) forControlEvents:UIControlEventEditingDidEndOnExit];//把DidEndOnExit事件响应为 textfieldDone: 方法        [cell.contentView addSubview: textField];
?

?

?

热点排行