繁体   English   中英

UITextField作为UITableView中的子视图

[英]UITextField as subview in a UITableView

如何实现我们可以在Skype应用程序的登录视图中看到的东西?

对我来说,它看起来像一个表格视图,其中的UILabel和UITextField作为子视图。 我从未做过类似的事情,所以我想知道我该怎么做。

你可以这样做。 检查以下代码

- (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)];
    startDtLbl.backgroundColor = [UIColor clearColor];
    startDtLbl.tag = 1;
    [cell.contentView addSubview:startDtLbl];

    UITextField *passwordTF = [[UITextField alloc] initWithFrame:CGRectMake(100, 5, 200, 35)];
    passwordTF.tag = 2;
    [cell.contentView addSubview:passwordTF];
    }
    return cell;
}

您可以添加上述字段。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM