2013-07-01 70 views
0

单击它时我如何使单元格变大?单击时使tableView单元格变大

这是我目前无法使用的代码。

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    UITableViewCell *cell = [feedsTableView dequeueReusableCellWithIdentifier:@"MyIdentifier"]; 
    static NSString *CellIdentifier = @"Cell"; 
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] ; 

    ell.frame = CGRectMake(cell.frame.origin.x, cell.frame.origin.y, 320.0, 250.0); 
    NSLog(@"[CELL CLICK] %i", indexPath.row); 

    [feedsTableView beginUpdates]; 
    [feedsTableView endUpdates]; 

    [feedsTableView deselectRowAtIndexPath:indexPath animated:YES]; 
} 

回答

2

你可以做这样的事情:

NSIndexPath *selectedIndex; 

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    if (indexPath == selectedIndex) 
    return 80.0f; 
    else 
    return 50.0f; 
} 

然后在didSelectRowAtIndex设置selectedIndex变量并重新加载这样的实现代码如下:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    selectedIndex = indexPath; 
    [tableView reloadRowsAtIndexPaths:indexPath withRowAnimation:UITableViewRowAnimationMiddle]; 
}