UITableViewCell
単品での人気コーナーとしてはNSArray
?イベントの配列があり、データを にロードしますcellForRowAtIndexPath
。年イベントごとにセクションを作成する必要があります。
例:
section 2012
Date: 01/01/2012
Event: Live Music
Date: 01/02/2012
Event: Live Music
section 2011
Date: 01/01/2011
Event: Live Music
Date: 01/02/2011
Event: Live Music
セルには既に値が設定されています。セクションへの分割、2 つ (最大 2 年) を作成するセクションだけが欠けています。
申し訳ありませんが、まだ少し混乱しています。解決できません。助けてください。今年のテストはいつですか?コードを投稿します、どうもありがとう
-(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";
}
}