gpt4 book ai didi

iphone - iOS:用于登录屏幕的表格样式 TextField?

转载 作者:技术小花猫 更新时间:2023-10-29 10:32:29 24 4
gpt4 key购买 nike

我想制作一个登录屏幕,就像 Facebook 应用程序中的那样。我想要复制的部分是两个文本字段,它们堆叠时看起来像一个表格组。不过我不知道他们是怎么做到的。

谁知道诀窍?

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

最佳答案

您可以使用下面的代码。

//在.h文件中

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;
}

关于iphone - iOS:用于登录屏幕的表格样式 TextField?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7748997/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com