2013-09-04 6 views
-1

버튼을 클릭하면 팝업 뷰가 표시되고 나머지 셀은 애니메이션처럼 아래쪽으로 애니메이션됩니다. 셀 하위보기가 있으면 하위 수준 셀을 클릭하면 다음 수준의 하위 셀이 열립니다. 의 tableview 아래 이미지테이블 뷰 셀의 버튼을 클릭하면 뷰가 팝업됩니다.

Table view

셀 및 서브 셀이 같은 있어야

The table view must be like this

같을한다. 어느 누구도 나를 도울 수 있습니까?

답변

1

나는 이것을 전에했다. 다음 코드를 사용하십시오. 셀 뷰에서 셀 뷰와 뷰 뷰가있는 사용자 정의 셀 클래스를 만들고 heightforrowatindexpath 메서드 uitableview 클래스를 사용하여 표시 할 뷰만 표시합니다. 코드는 다음과 같습니다

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 
{ 
    return 1; 
} 

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{ 
    return 10; 
} 

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath; 
{ 
    if (checkHeight == indexPath.row) 
     return 185; 
    else 
     return 80; 
} 

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

    FAQCell *cell = (FAQCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    if (cell == nil) 
    { 
     [[NSBundle mainBundle] loadNibNamed:@"FAQCell" owner:self options:nil]; 
     cell = myCell; 
     myCell = nil; 
    } 

    cell.selectionStyle = UITableViewCellSelectionStyleNone; 
    [cell.quesText setFont:[UIFont fontWithName:@"CaviarDreams" size:16]]; 
    [cell.ansText setFont:[UIFont fontWithName:@"CaviarDreams" size:16]]; 


    // check for the row for which the background color has to be changed 
    if (checkHeight == indexPath.row) 
     [cell.bgView setBackgroundColor:[UIColor colorWithRed:0.3333 green:0.7373 blue:0.4588 alpha:1.0]]; 
    else 
     [cell.bgView setBackgroundColor:[UIColor colorWithRed:0.9176 green:0.3765 blue:0.2980 alpha:1.0]]; 

    return cell; 
} 

#pragma mark - 
#pragma mark Tableview Delegate Methods 

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    // Deselect cell 
    [tableView deselectRowAtIndexPath:indexPath animated:TRUE]; 
    checkHeight = indexPath.row; 

    // reload the data of the table 
    [tableView reloadSections:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, tableView.numberOfSections)] withRowAnimation:UITableViewRowAnimationAutomatic]; 
} 

문제가 있으면 알려주세요.

+0

안녕하세요 감사하지만, 위 그림과 같이 내 요구 사항이 다릅니다. 하위 셀이 열리고 전체 데이터가 동적입니다. – user2164763

관련 문제