2009-10-03 4 views
1

저는 CustomCell에 많은 기능을 추가했습니다. 요구 사항은 그룹화 된 TableView의 경우 단일 UITableViewCell을 탭하면 아래에 확장되고 아래쪽으로 약간 움직여 확장되어야하며 해당 셀에 더 많은 정보가 표시되어야합니다.터치시 확장되고 uitextfield를 포함하는 사용자 정의 UITableViewCell

이미 확장 된 셀을 누르면 "정상적인"셀 상태로 돌아갑니다.

내가 여기에있을 수있는 모든 방향이 좋을 것 ..

또한, 다음과 같은 코드를 살펴 셀에 대한 변수가 나는 그러나, cell.acccessoryVIew에 이미지를 추가 해요, 안에 이미지를 추가하는 코드를 작성하는 몇 가지 예가 있습니다 (if cell == nil) {}.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
    static NSString *kCustomCellID = @"MyCellDetailSym"; 
    CustomCell *cell = (CustomCell *)[self.tableView dequeueReusableCellWithIdentifier:kCustomCellID]; 
    if (cell == nil) 
    { 
     cell = (CustomCell *)[[[CustomCell alloc] initWithFrame:CGRectZero reuseIdentifier:kCustomCellID] autorelease]; 

    } 
    cell.checkNeeded = YES; 
    appdelegate *appDelegate = (appdelegate *)[[UIApplication sharedApplication] delegate]; 
    customClass *nSym = (customClass *)[ArrayCache objectAtIndex:indexPath.row]; 
    if([appDelegate.sMap containsObject:[NSString stringWithFormat:@"%d",[nSym pKey]]]) { cell.checked=YES; } else cell.checked = NO; 
    if([appDelegate.favoriteSymArray containsObject:[NSString stringWithFormat:@"%d",[nSym pKey]]]) { cell.starred=YES; } else cell.starred = NO; 
    cell.title = nSym.txtSym; 

    UIImage *starredImage = [UIImage imageNamed:@"Star_list_active.png"]; 
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; 
    CGRect frame = CGRectMake(0.0, 0.0, starredImage.size.width + 5 , starredImage.size.height + 5); 
    button.frame = frame; 

    UIImage *image = (cell.starred) ? starredImage: [UIImage imageNamed:@"Star_list_inactive.png"]; 
    //UIImage *newImage = [image stretchableImageWithLeftCapWidth:12.0 topCapHeight:0.0]; 
    [button setEnabled:YES]; 
    [button setBackgroundImage:image forState:UIControlStateNormal]; 
    [button addTarget:self action:@selector(checkButtonTapped:event:) forControlEvents:UIControlEventTouchUpInside]; 
    button.backgroundColor = [UIColor clearColor]; 
    cell.accessoryView = button; 

    return cell; 

} 

들 덕분에

답변

0

내가 이런 짓을하는 방법은 삽입 행으로 다음 행을 지정하고 드롭 다운 효과를 만드는 UITableViewRowAnimationTop와 애니메이션 - (void)insertRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation 전화를했다. 셀 확장 "환상을 완료하려면 separatorColor이 배경과 일치하는지 확인하십시오.

대리인 메서드를 호출하여 행 높이의 크기를 조정하지 마십시오. 내가 말할 수있는 한 그것은 움직이지 않을 것이다.

관련 문제