2013-01-23 2 views
1

동적 인 UITableView에 공급되는 두 가지 다른 유형의 데이터 사이에 signifier를 넣으려고합니다. 데이터를 두 섹션으로 나눌 수 있습니까? 아니면 비 -userInteractionEnabled 셀을 피드에 입력하여 분할을 표시해야합니까? 프로그래밍 방식으로 numberOfSections 속성을 설정할 수 없습니다. 누구든지이 문제를 해결하는 방법을 알고 있습니까? 당신이 당신의 테이블보기를있는 tableview 옵션을 그룹화 선택했다 당신이 그룹화 된 테이블보기를 만드는 일을하려고하는, 당신의 인터페이스 빌더에서 확인Dynamic UITableView를 섹션으로 나눌 수 있습니까?

+1

예는 호출 될 때 그룹화의 tableview 섹션을'넣어 er) numberOfSectionsInTableView : (UITableView *) tableView { return 2; }'당신의 tableview에 http://www.mobisoftinfotech.com/blog/iphone/iphone-uitableview-tutorial-grouped-table/을보십시오 –

+0

왜'numberOfSections'을 설정할 수 없습니까? –

+0

@SpaceDust, 답변으로 추가해야합니다. – iDev

답변

1

다음 그룹화 호출 테이블 뷰 방법 등

// for sections I guess you want 2 sections 
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 
    return 2; 
} 

- (NSInteger)tableView:(UITableView *)tableView 
numberOfRowsInSection:(NSInteger)section { 
    if(section==0) 
     return [yourdatasource count]; // make sure that each section is returned here 
    if(section==1) 
     return [anotherdatasource count]; 
} 

// set header height of gropued tableview 
-(CGFloat)tableView:(UITableView*)tableView heightForHeaderInSection:(NSInteger)section { 

    return 60.0; // choose your height for each section 
} 
//set header section labels 
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { 
} 

로 (NSInteg -

내 코드 테스트되지 않은 추가 정보를 원하시면이 http://www.mobisoftinfotech.com/blog/iphone/iphone-uitableview-tutorial-grouped-table/에서

봐는

관련 문제