开发者

UITextField as subview in a UITableView

开发者 https://www.devze.com 2023-02-01 18:22 出处:网络
How can I achieve something that we can see on l开发者_如何学Pythonogin view of Skype app? It looks like a table View to me with UILabel and UITextField inside it as a subview. I\'ve never done somet

How can I achieve something that we can see on l开发者_如何学Pythonogin view of Skype app?

It looks like a table View to me with UILabel and UITextField inside it as a subview. I've never done something like so I'd like to know how can I do that.


You can do this. Check 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)];
    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;
}

You can add the fields like the above.

0

精彩评论

暂无评论...
验证码 换一张
取 消