Для табличного представления я использую два массива, один для заголовка раздела таблицы и другой для строк таблицы, если пользователь выбирает заголовок раздела таблицы, я показываю количество строк в этом разделе, мой код работает нормально, но я хочу показать некоторые анимации при отображении данных раздела может помочь мне, я новичок в моем телефоне. Заранее спасибо
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"CellIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
UIView *backview = [[UIView alloc]initWithFrame:CGRectMake(0, 0, cell.frame.size.width, 30)];
[backview setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"strip_s12A-1.png"]]];
cell.backgroundView = backview;
[backview release];
UIView *selectview = [[UIView alloc]initWithFrame:CGRectMake(0, 0, cell.frame.size.width, 30)];
[selectview setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"strip_s12A-1_h.png"]]];
cell.selectedBackgroundView = selectview;
[selectview release];
UILabel *cellTitle=[[UILabel alloc]initWithFrame:CGRectMake(30, 0, 300, 30)];
cellTitle.adjustsFontSizeToFitWidth=YES;
[cellTitle setBackgroundColor:[UIColor clearColor]];
[cellTitle setFont:[UIFont fontWithName:@"Helvetica-Bold" size:17]];
[cellTitle setTextColor:[UIColor blackColor]];
cellTitle.tag=100+indexPath.row;
cellTitle.text=[[_cellArray objectAtIndex:indexPath.row] valueForKey:@"ProductGuid"];
[cell.contentView addSubview:cellTitle];
[cellTitle release];
}
return cell;
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
tableView.separatorStyle=UITableViewCellSeparatorStyleNone;
headerView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 294, 40)];
if (searching)
{
[headerView setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"strip_s10.png"]]];
//Button
UIButton *button=[UIButton buttonWithType:UIButtonTypeCustom];
button.frame=CGRectMake(0, 0, 320, 40);
button.tag = section+1;
[button addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
[button setImage:[UIImage imageNamed:@"strip_s12A_h.png"] forState:UIControlStateNormal];
[button setImage:[UIImage imageNamed:@"strip_s12A(2).png"] forState:UIControlStateSelected];
if([[cellCount objectAtIndex:section] intValue]==0) button.selected=YES;
else button.selected=NO;
[headerView addSubview:button];
//Label
UILabel *headerTitle=[[UILabel alloc]initWithFrame:CGRectMake(20, 5, 300, 30)];
headerTitle.adjustsFontSizeToFitWidth=YES;
[headerTitle setBackgroundColor:[UIColor clearColor]];
[headerTitle setFont:[UIFont fontWithName:@"Helvetica-Bold" size:17]];
[headerTitle setTextColor:[UIColor blackColor]];
headerTitle.text=[[temp_details objectAtIndex:section] valueForKey:@"InventoryLocationGuid"];
[headerView addSubview:headerTitle];
[headerTitle release];
return headerView;
}
else {
[headerView setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"strip_s10.png"]]];
UIButton *button=[UIButton buttonWithType:UIButtonTypeCustom];
button.frame=CGRectMake(0, 0, 320, 40);
button.tag = section+1;
[button addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
[button setImage:[UIImage imageNamed:@"strip_s12A_h.png"] forState:UIControlStateNormal];
[button setImage:[UIImage imageNamed:@"strip_s12A(2).png"] forState:UIControlStateSelected];
if([[cellCount objectAtIndex:section] intValue]==0) button.selected=YES;
else button.selected=NO;
[headerView addSubview:button];
UILabel *headerTitle=[[UILabel alloc]initWithFrame:CGRectMake(20, 5, 300, 30)];
headerTitle.adjustsFontSizeToFitWidth=YES;
[headerTitle setBackgroundColor:[UIColor clearColor]];
[headerTitle setFont:[UIFont fontWithName:@"Helvetica-Bold" size:17]];
[headerTitle setTextColor:[UIColor blackColor]];
headerTitle.text=[[InventoryGroup objectAtIndex:section] valueForKey:@"InventoryLocationGuid"];
[headerView addSubview:headerTitle];
[headerTitle release];
if (!flag) {
[cellCount replaceObjectAtIndex:button.tag-1 withObject:[NSNumber numberWithInt:0]];
}
return headerView;
}
-(void)buttonClicked:(id)sender
{
UIButton *button2 = (UIButton *)sender;
NSInteger _index = [sender tag]-1;
if(![button2 isSelected])
[cellCount replaceObjectAtIndex:_index withObject:[NSNumber numberWithInt:0]];
else
[cellCount replaceObjectAtIndex:_index withObject:[NSNumber numberWithInt:[[cellArray objectAtIndex:_index]count]]];
flag=TRUE;
//[self.tableView reloadRowsAtIndexPaths:_index withRowAnimation:UITableViewRowAnimationFade];
[self.tableView reloadData];