인기 섹션으로 UITableViewCell
에 NSArray
? 이벤트 배열이 있으며 cellForRowAtIndexPath
에 데이터를로드하십시오. 연도 별 이벤트를 만들어야합니다.
예 :
섹션 2012
날짜 : 01/01/2012
이벤트 : 라이브 음악
날짜 : 2012년 1월 2일
이벤트 : 라이브 음악
section 2011
날짜 : 01/01/2011
이벤트 : 라이브 뮤직
날짜 : 2011년 1월 2일
이벤트 :
세포가 이미 채워진
단일 NSArray를 사용하여 UITbleViewCell에서 섹션을 만드는 방법은 무엇입니까?
, 나는 부분으로 만 분할을 그리워 라이브 뮤직, 섹션이 두 개 (최대 2 년)을 만듭니다.
죄송 합니다만, 아직 해결되지 않을 수 있습니다. 시험을 치르시겠습니까? 제발 도와주세요.
cell.textlabel.text = [NSString stringWithFormat:@"%@/n%@/n%@",[array1 ObjectAtIndex:row],......];
을 또한 당신이 가지고 : 나는 cell.textlabel.text이
시도 감사에게, 많은
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
//acquisisco la data dell'evento
NSString *dataEv = [[events objectAtIndex:indexPath.row + indexPath.section]DataEvento];
//retrive year ,example 2011, 2012 when test?
NSString *Year = [Utility getPartOfDate:dataEv type:UTLGetYear];
//set image
...
[cell.contentView addSubview:myImg];
//set day
day.text = [Utility getPartOfDate:dataEv type:UTLGetNumberOfDay];;
[cell.contentView addSubview:day];
//set dayOfWeek
...
dayOfWeek.text = [Utility getPartOfDate:dataEv type:UTLGetDayOfWeek];;
[cell.contentView addSubview:dayOfWeek];
//set month
month.text = [Utility getPartOfDate:dataEv type:UTLGetTextMonth];;
[cell.contentView addSubview:month];
//set title
...
lblTitleEvent.text = [[eventi objectAtIndex:indexPath.row + indexPath.section]Artist];
[cell.contentView addSubview:lblTitoloEvento];
//set description event
lblDescEvento.text = [[eventi objectAtIndex:indexPath.row + indexPath.section]Description];
[cell.contentView addSubview:lblDescriptionEvent];
}else{
lblTitleEvent = (UILabel*)[cell.contentView viewWithTag:5];
lblTitleEvent.text = [[events objectAtIndex:indexPath.row + indexPath.section]Artista];
lblDescEvent = (UILabel*)[cell.contentView viewWithTag:6];
lblDescEvent.text = [[events objectAtIndex:indexPath.row + indexPath.section]Description];
}
return cell;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 2;
}
// Customize the number of rows in the table view.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [events count];
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
if(section == 0){
return @"Section 1";
}
if(section == 1){
return @"Section 2";
}
}
년을 키로하여 사전에서 배열을 변형하는 방법에 대해 설명합니다. 키의 수는 테이블의 섹션 수와 요소의 수입니다. 각 키는 각 섹션의 행 수입니다 ... –