Hi. i have a scrollview which contains a uitableview and few buttons. i have added the uitableview from IB. and the table cells are created dynamically. i am adding a lable and a textfield for each table cell(Something like an input form for the user.) I have written code to resize the scrollview when the keyboard appears. So when i click on a textfield the keyboard comes up and takes up half of the screen, and scrollview takes the other half. the problem is , as soon as this happens, the tableview is altered and shows only the first cell of the table.I think the tableview gets clipped. No matter what i do, the tableview does not show the entire table... so wat am i doing wrong.
Heres my code.
- (void)viewDidLoad
{
[super viewDidLoad];
scrollView.contentSize=self.view.frame.size;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell= [[tableView dequeueReusableCellWithIdentifier:CellIdentifier] autorelease];
if (cell==nil) {
CGFloat fontSize = [UIFont labelFontSize]-3 ;
CGFloat topMargin = floor(0.5 * (tableView.rowHeight - fontSize)) -2;
cell = [[[UITableViewCell alloc]
initWithFrame:CGRectMake(0, 0, 320, tableView.rowHeight)
reuseIdentifier:CellIdentifier]
autorelease];
UILabel *labelHeading = [[[UILabel alloc]initWithFrame:CGRectMake(10.0, topMargin, 100.0, fontSize + 4)] autorelease];
labelHeading.text= [[self.menuItems objectAtIndex:indexPath.row] objectForKey:@"itemName"];
[cell addSubview:labelHeading];
txtValue = [[[UITextField alloc] initWithFrame:CGRectMake(120,topMargin,150 ,fontSize + 4)] autorelease];
txtValue.text=[NSString stringWithFormat:@" %@",[dataItems objectForKey:@"name"]];
[cell addSubview:txtValue];
[scrollView addSubview:cell];
}
return cell;
}
So can somebody help me. nybody got ideas?