当用户选择带有弹跳动画的单元格时,我想全屏设置UITableViewCell
。我在下面分享了链接。我想要这样的。
https://drive.google.com/open?id=0B9k_Shyb5v62eFdxWXhYeXV3a0E
我在单元格中设置视图。但我不能用动画全屏设置它。
以下是我的代码:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableViewList cellForRowAtIndexPath:indexPath];
int index = [cell.accessibilityIdentifier intValue];
CGFloat delay = 0.0f;
if (indexSelected == (int)indexPath.row)
{
//COLLAPSE
indexSelected = -1111111111;
UIView *viewController = (UIView *)[cell.contentView viewWithTag:TAG_DETAIL_CONTROLLER];
[viewController removeFromSuperview];
tableViewList.frame = frameTableViewList;
[tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
btnBack.hidden = YES;
indexSelected = -1;
}
else
{
//EXPAND
if (indexSelected < 0)
indexSelected = index;
else
{
int indexPrevious = indexSelected;
indexSelected = (int)indexPath.row;
[tableView reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:indexPrevious inSection:0]] withRowAnimation:UITableViewRowAnimationNone];
delay = 0.3;
}
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delay * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
CGRect frame = tableViewList.frame;
frame.origin.y = 0;
frame.size.height = CGRectGetHeight(self.view.frame);
tableViewList.frame = frame;
btnBack.hidden = NO;
});
}
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil)
cell = [self reuseTableViewCellWithIdentifier:cellIdentifier];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
UIView *viewController = (UIView *)[cell.contentView viewWithTag:TAG_DETAIL_CONTROLLER];
if (indexSelected >= 0 && indexSelected == (int)indexPath.row)
[self addDiamondDetailView:cell index:(int)indexPath.row];
else
{
if (indexSelected == -1111111111)
{
CGRect frame = cell.frame;
frame.size.height = cellHeight;
cell.frame = frame;
cell.contentView.frame = CGRectMake(0, 0, CGRectGetWidth(cell.frame), CGRectGetHeight(cell.frame));
}
[viewController removeFromSuperview];
}
cell.contentView.clipsToBounds = YES;
return cell;
}
- (void)addDiamondDetailView:(UITableViewCell *)cell index:(int)index
{
DetailVC = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil];
DetailVC.selectedStoneInfo = (StoneInfo *)[arrStone objectAtIndex:index];
DetailVC._STONE_DETAIL_TYPE = self._RESULT_PAGE_TYPE == RESULT_MY_CART ? STONE_DETAIL_CART : STONE_DETAIL_RESULT;
DetailVC.delegate = self;
DetailVC.view.tag = TAG_DETAIL_CONTROLLER;
[cell.contentView addSubview:stoneDetailVC.view];
//Cell Frame
CGRect frame = cell.bounds;
frame.size.height = cellDetailHeight;
cell.frame = frame;
cell.contentView.frame = CGRectMake(0, 0, CGRectGetWidth(cell.frame), CGRectGetHeight(cell.frame));
//Stone Detail VC Frame
frame = stoneDetailVC.view.frame;
DetailVC.view.frame = CGRectMake(0, 0, CGRectGetWidth(stoneDetailVC.view.frame), cellDetailHeight);
}
我已将ViewController
作为子视图添加到单元格中。我想在全屏幕中使用反弹动画设置表格单元格。请帮帮我。