UITextField as subview in a UITableView
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.
精彩评论