2010-02-07 24 views
1

我有一個用於UITableViewCell子類的nib文件,它的高度在nib中設置爲25,但是當應用程序加載時,情況並非如此。它加載到默認大小。這是我的代碼實施的單元格。UITableViewCell子類沒有顯示正確的大小

// Customize the appearance of table view cells. 
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    static NSString *CellIdentifier = @"MyCell"; 

    MyCell *cell = (MyCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    if (cell == nil) 
    { 
     [[NSBundle mainBundle] loadNibNamed:@"MyCell" owner:self options:nil]; 
     //cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; 
     cell = choreCell; 
    } 
    return cell; 
} 

我試着用cell.frame = CGRectMake(0, 0, 320, 25)設置框架,但它沒有工作。有任何想法嗎?

回答

3

單元格高度在表視圖委託的-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath方法中指定。

+0

啊,非常感謝! – skylerl 2010-02-08 00:14:28