Objective c 我需要在ios 8中实现可扩展的tableView单元

Objective c 我需要在ios 8中实现可扩展的tableView单元,objective-c,ios8,Objective C,Ios8,在我的项目中,我需要实现UITableview,其中一些tableView单元是可扩展的,一些是独立的。如果是可展开单元,则需要指示“+”符号。请在此处输入图像描述。谁能帮我一下吗我制作了一个小演示 屏幕截图1:展开单元格之前 屏幕截图2:展开单元格后 对于每个可扩展单元,您都必须这样管理。 希望这能对你有所帮助。我制作了一个小演示 屏幕截图1:展开单元格之前 屏幕截图2:展开单元格后 对于每个可扩展单元,您都必须这样管理。 希望这将对您有所帮助。尝试此控件: 它支持你所说的。点击单元格

在我的项目中,我需要实现UITableview,其中一些tableView单元是可扩展的,一些是独立的。如果是可展开单元,则需要指示“+”符号。请在此处输入图像描述。谁能帮我一下吗

我制作了一个小演示

屏幕截图1:展开单元格之前

屏幕截图2:展开单元格后

对于每个可扩展单元,您都必须这样管理。
希望这能对你有所帮助。

我制作了一个小演示

屏幕截图1:展开单元格之前

屏幕截图2:展开单元格后

对于每个可扩展单元,您都必须这样管理。 希望这将对您有所帮助。

尝试此控件: 它支持你所说的。点击单元格可将其展开。

尝试此控件:
它支持你所说的。点击一个单元格可以扩展它。

我仍然没有得到完美的解决方案,我正在寻找类似Jabong android应用程序滑块菜单或swift3的代码,检查此链接我仍然没有得到完美的解决方案,我正在寻找类似Jabong android应用程序滑块菜单或swift3的代码,检查此链接以获得swift3,使用此链接以获得swift3,使用此链接
@interface ViewController ()
<UITableViewDataSource,
UITableViewDelegate>
{
    UITableView *tblView;

    NSArray *cell0SubMenuItemsArray;

    BOOL isSection0Cell0Expanded;
}

@end

@implementation ViewController

# pragma mark - View Life Cycle

- (void)viewDidLoad
{
    [super viewDidLoad];


    tblView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];
    tblView.backgroundColor = [UIColor clearColor];
    tblView.delegate = self;
    tblView.dataSource = self;
    tblView.allowsSelection = YES;
    tblView.scrollEnabled = YES;
    tblView.alwaysBounceVertical = YES;
    [self.view addSubview:tblView];

    cell0SubMenuItemsArray = @[@"First Static Menu Item", @"Second Static Menu Item", @"Third Static Menu Item"];
}

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];

    [self.view setNeedsLayout];
}

- (void)viewDidLayoutSubviews
{
    [super viewDidLayoutSubviews];

    [self updateViewDimensions];
}

- (void)updateViewDimensions
{
    tblView.frame = CGRectMake(0, 40, 320, 550);
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
}

# pragma mark - UITableView Delegate and Datasource

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (section == 0)
    {
        int cellCount = 2; // Default count - if not a single cell is expanded

        if (isSection0Cell0Expanded)
        {
            cellCount += [cell0SubMenuItemsArray count];
        }

        return cellCount;
    }

    return 0;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *strCellId = @"CellId";

    UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:strCellId];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;

    if (indexPath.section == 0)
    {
        if (indexPath.row == 0)
        {
            cell.textLabel.text = @"Expandable Cell";

            UIImageView *accessoryImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];

            if (isSection0Cell0Expanded) // Set accessory view according to cell state - EXPANDED / NOT EXPANDED
            {
            accessoryImageView.image = [UIImage imageNamed:@"Minus.png"];
            cell.detailTextLabel.text = @"Status : Expanded";
        }
        else
        {
            accessoryImageView.image = [UIImage imageNamed:@"Plus.png"];
            cell.detailTextLabel.text = @"Status : Not Expanded";
        }

            cell.accessoryView = accessoryImageView;
        }
        else
        {
            if (isSection0Cell0Expanded && [cell0SubMenuItemsArray count] >= indexPath.row) // Check Expanded status and do the necessary changes
            {
                cell.textLabel.text = [NSString stringWithFormat:@"%@", [cell0SubMenuItemsArray objectAtIndex:indexPath.row - 1]];
            }
            else
            {
                cell.textLabel.text = @"Static Cell";
            }
        }
    }

    return cell;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 0)
    {
        // Change status of a cell reload table

        isSection0Cell0Expanded = !isSection0Cell0Expanded;
        [tblView reloadData];
    }
}