iOS:登录屏幕的表格式TextField? [英] iOS: Table-style TextField for Login Screen?

查看:140
本文介绍了iOS:登录屏幕的表格式TextField?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Facebook的应用程序中创建一个登录界面。我要复制的部分是两个文本字段,堆叠时看起来像一个表组。我不知道他们是怎么做到的。

I wanna make a login screen like the one from Facebook's app. The part I wanna replicate is the two text fields that when stacked look like a table group. I can't figure out how they did it though.

谁知道诀窍?

我可以'发布图片因为我是stackoverflow的新手。这是一种效果,它们看起来像一个圆形椭圆形但内部有2个文本字段。一个用于用户名,一个用于密码。

I can't post a picture because I am new to stackoverflow. It's an effect that they seem like one rounded oval but with 2 text fields inside. One for username, one for password.

推荐答案

您可以使用以下代码。

// in .h文件

//in .h file

UITextField *loginId; 
UITextField *password ;

//在.m文件中

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
        return 2;
    }
    - (UITableViewCell *)tableView:(UITableView *)table cellForRowAtIndexPath:(NSIndexPath *)indexPath {

        UITableViewCell *cell = [table dequeueReusableCellWithIdentifier:@"Cell"];
        if( cell == nil)
            cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"] autorelease];   

        if (indexPath.row == 0) {
            loginId = [[UITextField alloc] initWithFrame:CGRectMake(5, 0, 280, 21)];
            loginId .placeholder = @"loginid";
            loginId .autocorrectionType = UITextAutocorrectionTypeNo;
            [loginId setClearButtonMode:UITextFieldViewModeWhileEditing];
            cell.accessoryView = loginId ;
        }
        if (indexPath.row == 1) {
            password = [[UITextField alloc] initWithFrame:CGRectMake(5, 0, 280, 21)];
            password.placeholder = @"Password";
            password.secureTextEntry = YES;
            password.autocorrectionType = UITextAutocorrectionTypeNo;
            [password setClearButtonMode:UITextFieldViewModeWhileEditing];
            cell.accessoryView = password;
        }
        loginId.delegate = self;
        password.delegate = self;


        [tableView1 addSubview:loginId];
        [tableView1 addSubview:password];
        [loginId release];
        [password release];

        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        return cell;  
    }
    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{

        return 1;
    }

这篇关于iOS:登录屏幕的表格式TextField?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆