2012-10-28 2 views
0

사용자 지정 UITableViewCell이있는 테이블보기에서 사이드 메뉴를 만들고 있습니다.여러 다른 사용자 지정 셀을 사용하여 복잡한 UITableView 만들기

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

if (cell == nil) { 

    NSArray* views = [[NSBundle mainBundle] loadNibNamed:@"LeftMenuTableViewCell" owner:nil options:nil]; 

    for (UIView *view in views) { 
     if([view isKindOfClass:[UITableViewCell class]]) 
     { 
      cell = (LeftMenuTableViewCell*)view; 
      [cell.displayName setText:[NSString stringWithFormat:@"Cell 1"]; 

     } 
    } 
} 

return cell; 

} 나는이 테이블에 대해 다른 세포를 만드는 방법을 알고 싶습니다

:

나는 다음에 사용되는 재사용 가능한 셀을 만들었습니다. 테이블은 Facebook/Path 사이드 메뉴와 같습니다. 예를 내 프로필 설정 도움말 로그 아웃을 위해

은, 동일한 디자인을했을 레이블과 그 옆의 아이콘을 다른 텍스트하지만. 또한 다른보기 컨트롤러를 오른쪽에로드합니다. 누군가 어떻게 이것이 이루어 졌는지 설명 할 수 있습니까? 또는 여러 개의 다른 셀이있는 사용자 정의 테이블 뷰를 만드는 방법을 설명하는 자습서에 대한 링크를 제공하십시오. 셀 .h, .m 및 NIB 파일을 복제하고 각 사용자 정의 UITabelViewCell을 개별적으로 작성해야합니까?

답변

0

, 동일한 셀 클래스를 사용하고 (셀 만 텍스트와 이미지에 어떤 디자인 변화가 없기 때문에 변화)로 넣어

didSelectRowAtIndexPath 방법에서
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    //some code 
    if() { //condition 1 
    cell.textLabel.text = @"My Profile"; 
    cell.imageView.image = [UIImage imageNamed:@"MyProfile.png"]; 
    } else if() { //condition 2 
    cell.textLabel.text = @"Settings"; 
    cell.imageView.image = [UIImage imageNamed:@"Settings.png"]; 
    } else if() { //condition 3 
    cell.textLabel.text = @"Logout"; 
    cell.imageView.image = [UIImage imageNamed:@"Logout.png"]; 
    } 
    //some code 
} 

,

if() { //condition 1, say indexpath.row == 0 
    //go to firstviewcontroller 
} else if() { //condition 2, say indexpath.row == 1 
    //go to secondviewcontroller 
} else if() { //condition 3, say indexpath.row == 2 
    //go to thirdviewcontroller 
} 

이를 너에게 옳은가?

+0

예 : 문자 수 – StuartM

관련 문제