2012-08-28 3 views
0

나는 3 개의 레이블, 이름, 책 및 장으로 구성된 사용자 정의 셀이있는 tableView를 가지고 있습니다. 불행히도 내 세포가 3 개의 레이블에 충분하지 않아서 그것을 더 크게 만들고 싶습니다. 최선의 방법으로 이것을 달성하려면 아래 코드에서 무엇을해야합니까? /를있는 tableView에서 셀의의tableView의 셀 크기를 늘리시겠습니까?

사진을 안부 : http://tinypic.com/view.php?pic=2vrzpu9&s=6

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
static NSString *CellIdentifier = @"BookmarkCell"; 
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 

if (cell == nil) 
{ 
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; 
} 
Bookmark *item = [self.items objectAtIndex:indexPath.row]; 

NSArray *chunks = [item.name componentsSeparatedByString: @","]; 

NSString *name; 
NSString *book; 
NSString *chapter; 

if ([chunks count] > 0) 
{ 
    name = [chunks objectAtIndex:0]; 
    if ([chunks count] > 1) 
    { 
     book = [chunks objectAtIndex:1]; 
     if ([chunks count] > 2) 
     { 
      chapter = [chunks objectAtIndex:2]; 
     } 
    } 
} 

UIView * pNewContentView= [[UIView alloc] initWithFrame:cell.contentView.bounds]; 
CGRect labelFrame= pNewContentView.bounds; 
labelFrame.size.height= labelFrame.size.height * 0.25; 

UILabel* pLabel1=[[UILabel alloc] initWithFrame:labelFrame]; 
[pNewContentView addSubview:pLabel1]; 

labelFrame.origin.y= labelFrame.size.height; 
UILabel* pLabel2=[[UILabel alloc] initWithFrame:labelFrame]; 
[pNewContentView addSubview:pLabel2]; 

labelFrame.origin.y= labelFrame.origin.y + labelFrame.size.height; 
UILabel* pLabel3=[[UILabel alloc] initWithFrame:labelFrame]; 
[pNewContentView addSubview:pLabel3]; 

[cell.contentView addSubview:pNewContentView]; 

[pLabel1 setText:(name)];  
[pLabel2 setText:(book)]; 
[pLabel3 setText:(chapter)];  


//cell.textLabel.text = chapter; 
//cell.textLabel.text = name; 
//cell.detailTextLabel.text = book; 


return cell; 
} 

답변

4

그것있는 UITableViewCell

의 높이를 사용자 정의하기 쉬운 바로 대리자 메서드

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath 
    return 70; // or whatever height you need 
} 
+0

고맙습니다을 추가, 그것은 일 ! –

관련 문제