iphone – iOS:桌面式TextField登录屏幕?
发布时间:2020-12-14 20:05:27 所属栏目:百科 来源:网络整理
导读:我想像Facebook的应用程序一样登录屏幕.我想要复制的部分是两个文本字段,当堆叠看起来像一个表组.我不知道他们是怎么做到的. 谁知道诀窍? 我不能张贴图片,因为我是新来的stackoverflow.这是一个效果,它们似乎是一个圆形椭圆形,但内部有2个文本字段.一个用于
我想像Facebook的应用程序一样登录屏幕.我想要复制的部分是两个文本字段,当堆叠看起来像一个表组.我不知道他们是怎么做到的.
谁知道诀窍? 我不能张贴图片,因为我是新来的stackoverflow.这是一个效果,它们似乎是一个圆形椭圆形,但内部有2个文本字段.一个用于用户名,一个用于密码. 解决方法
你可以使用下面的代码.
// in .h文件 UITextField *loginId; UITextField *password ; // in .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,280,21)]; loginId .placeholder = @"loginid"; loginId .autocorrectionType = UITextAutocorrectionTypeNo; [loginId setClearButtonMode:UITextFieldViewModeWhileEditing]; cell.accessoryView = loginId ; } if (indexPath.row == 1) { password = [[UITextField alloc] initWithFrame:CGRectMake(5,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; } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |