login using UITableView

Posted by EquinoX on Stack Overflow See other posts from Stack Overflow or by EquinoX
Published on 2011-02-21T06:40:42Z Indexed on 2011/02/21 7:25 UTC
Read the original article Hit count: 116

Filed under:
|
|

How can I create a login for username/password just like in the skype application? I know it's a grouped table view.. but how can I do that?

I searched the site and found the following code:

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

    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];

        UILabel *startDtLbl = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 80, 25)];
        if (indexPath.row == 0)
            startDtLbl.text = @"Username";
        else {
            startDtLbl.text = @"Password";
        }

        startDtLbl.backgroundColor = [UIColor clearColor];

        [cell.contentView addSubview:startDtLbl];

        UITextField *passwordTF = [[UITextField alloc] initWithFrame:CGRectMake(100, 5, 200, 35)];
        passwordTF.delegate = self;
        if (indexPath.row == 0)
            passwordTF.tag = 0;
        else {
            passwordTF.tag = 1;
        }
        [cell.contentView addSubview:passwordTF];
    }
    return cell;
}

When I do:

NSString * username = [((UITextField*)[self.view viewWithTag:0]) text];
NSString * password = [((UITextField*)[self.view viewWithTag:1]) text];

it gives me this error:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView text]: unrecognized selector sent to instance 0x6c3c600

Why is this?

© Stack Overflow or respective owner

Related posts about iphone

Related posts about objective-c