zoukankan      html  css  js  c++  java
  • 获取UITableView每行中不同的UITextField输入的内容(例如修改登陆密码)

    @interface AZTPasswordModifyViewController ()<UITableViewDelegate, UITableViewDataSource>{

            NSString *_theOldPassword ;

            NSString *_theNewPassword;

            NSString *_theTwiceNewPassword;

        }

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

    {

        NSInteger row = [indexPath row];

        

        static NSString  *CellIdentifier = @"CellIdentifier";

        

        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

        

        if (cell == nil) {

            cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];

            cell.selectionStyle = UITableViewCellSelectionStyleNone;

        }

        

        cell.textLabel.text = [_passwordArray objectAtIndex:row];

        

        CGRect textFieldRect = CGRectMake(0.0, 0.0f, 215.0f, 31.0f);

        UITextField *theTextField = [[UITextField alloc] initWithFrame:textFieldRect];

        theTextField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;

        theTextField.returnKeyType = UIReturnKeyDone;

        theTextField.secureTextEntry = YES;

        theTextField.clearButtonMode = YES;

        theTextField.tag = row;

        theTextField.delegate = self;

    //此方法为关键方法

        [theTextField addTarget:self action:@selector(textFieldWithText:)forControlEvents:UIControlEventEditingChanged];

        

        switch (row) {

            case 0:

                theTextField.placeholder = @"请输入旧密码";

                break;

            case 1:

                theTextField.placeholder = @"请输入新密码";

                break;

            case 2:

                theTextField.placeholder = @"请再次输入新密码";

                break;

            default:

                break;

        }

        

        cell.accessoryView = theTextField; 

        [theTextField release];

        

        return cell;

    }

    - (void)textFieldWithText:(UITextField *)textField

    {

        switch (textField.tag) {

            case 0:

                self.theOldPassword = textField.text;

                break;

            case 1:

                self.theNewPassword = textField.text;

                break;

            case 2:

                self.theTwiceNewPassword = textField.text;

                break;

            default:

                break;

        }

    }

  • 相关阅读:
    开发stark组件
    关于AJAX与form表单提交数据的格式
    博客小项目
    Django Orm 常用字段和参数
    IIS启用兼容模式设置(win2k3—Win7)
    C#调用java类、jar包方法(转)
    解决VML遭遇IE8和XHTML DOCTYPE时不能运行的问题(转)
    Nice Validator(Form验证)及Juery zTree控件
    ASP.NET程序中 抛出"Thread was being aborted. "异常(转)
    SQL语句Where中使用别名作为判断条件
  • 原文地址:https://www.cnblogs.com/hecheng0314/p/4604358.html
Copyright © 2011-2022 走看看