简体   繁体   English

在另一个TableView中的TableView单元格的Objective-c PushView

[英]Objective-c PushView for a cell of TableView in an other TableView

I have a problem by showing detail for a selected cell. 通过显示所选单元格的详细信息,我遇到了问题。 But this cell is in a TableView horizontal, and this TableView is in a cell of an other TableViewController. 但是,此单元格在水平的TableView中,而此TableView在另一个TableViewController的单元中。 I hope you can understand me. 希望你能理解我。

Here the code of the TableViewController (named HostingTableViewController) : 这里是TableViewController的代码(名为HostingTableViewController):

     - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        static NSString *CellIdentifier = @"CellWithTableInside";
        CellWithTableInside *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if (cell == nil) {
            cell = [[CellWithTableInside alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
        }
        cell.backgroundColor = [UIColor blackColor];

        NSArray *tabSection = [dictionarySection  keysSortedByValueUsingComparator:^NSComparisonResult(id obj1, id obj2){
            return [obj1 compare:obj2];
        }];
        NSArray* sortedNumbers = [tabSection sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) {
            if ([obj1 integerValue] > [obj2 integerValue]) {
                return (NSComparisonResult)NSOrderedDescending;
            }

            if ([obj1 integerValue] < [obj2 integerValue]) {
                return (NSComparisonResult)NSOrderedAscending;
            }
            return (NSComparisonResult)NSOrderedSame;
        }];

        id key,value;

            key = [sortedNumbers objectAtIndex: [indexPath section]];
            value = [dictionarySection objectForKey: key];

[cell setCellData:[dictionaryClip objectForKey:key]];

        return cell;
    }

Here the code for the Cell for show the detail controller : 这是显示细节控制器的Cell的代码:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{

    DetailClip *secondVC = [[DetailClip alloc]initWithClip:[array objectAtIndex:[indexPath row]]];
    [pushVC.navigationController pushViewController:secondVC animated:YES];


}

pushVC is init here : pushVC在这里是init:

pushVC = [[HostingTableViewController alloc]init];

Let me know if you need more informations, or code. 让我知道您是否需要更多信息或代码。

Thanks in advance :) 提前致谢 :)

If you confused in adding code on cell tap you can compare the tables & add the action by comparing its type (name of table) 如果您对在单元格上添加代码感到困惑,则可以比较表格并通过比较其类型(表格名称)来添加操作

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if(tableView==NameOfYourFirstTable)//first table view cell tap
{
    //write the code for your action
    DetailClip *secondVC = [[DetailClip alloc]initWithClip:[array objectAtIndex:[indexPath row]]];
    [pushVC.navigationController pushViewController:secondVC animated:YES];
}
else
{
    //actions on click of other table view cell 
}

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM