Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone UITableViewCell和UITableView(未选择行)导航到otherViewcontroller_Iphone - Fatal编程技术网

Iphone UITableViewCell和UITableView(未选择行)导航到otherViewcontroller

Iphone UITableViewCell和UITableView(未选择行)导航到otherViewcontroller,iphone,Iphone,我在一个视图中有一个UITableViewCell和UITableView。单击UITableView的特定行,它会导航到另一个ViewController。但我无法在单击UITableViewCell时导航到其他ViewController。我该怎么做 对于UITableView我使用以下代码: -(void)pushView1:(id)sender{ if(edController == nil) edController = [[EditableDetailCell all

我在一个视图中有一个
UITableViewCell
UITableView
。单击
UITableView
的特定行,它会导航到另一个ViewController。但我无法在单击
UITableViewCell
时导航到其他ViewController。我该怎么做

对于
UITableView
我使用以下代码:

-(void)pushView1:(id)sender{
    if(edController == nil)
    edController = [[EditableDetailCell alloc] initWithNibName:@"EditableDetailCell" bundle:[NSBundle mainBundle]];
    [self.navigationController pushViewController:edController animated:YES];
}
- (UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    UITableViewCell *tbcel;
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
    }
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    tbcel.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

    tbcel.layer.cornerRadius = 15;
    tbcel.text = aBook.Name;
    switch(indexPath.section)
    {
         case 0:
            cell.text = aBook.Address;
            break;
        case 1:
            cell.text = aBook.Phone;
            break;
        case 2:
            cell.text = aBook.Purchase;
    }
    return cell;
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if(edController == nil)
    edController = [[EditableDetailCell alloc] initWithNibName:@"EditableDetailCell" bundle:[NSBundle mainBundle]];
    [self.navigationController pushViewController:edController animated:YES];
}

我应该为UITableViewCell做什么

编辑:

您要推送的不是UITableViewCell

这是另一种观点

你可以说

YourCustomView *view = [[YourCustomView alloc] init];
[self.navigationController pushViewController:view animated:Yes];
但我从来没有看到任何代码传递到另一个细胞

单元格用于自定义UITableView的外观

加:

我认为if语句在这里没有用处

你是说

if(edController == nil){
    edController = [[EditableDetailCell alloc] initWithnibName:@"EditableDetailCell" bundle:[NSBundle mainBundle]];
    [self.navigationController pushViewController:edController animated:YES];
}

或者将以任何方式传递空视图。

UITableViewCell是表视图的一部分,对吗?那么,为什么要单独为其设置一个操作呢?它是一个UiTableViewCell,不包含在Tableview中,它是通过interface builder库单独插入到视图中的。它是否来自IB或任何东西都无关紧要。UITableViewCell不用于此目的。看到我下面的答案。这个奇怪的傀儡吓坏了我。我正在尝试按下这里的View1方法,让tableviewcell(客户2)导航,但没有使用此方法导航。您是否将其设置为iAction并将此方法与Interface Builder中的正确按钮相连接?图片旁边的customer2是一个按钮,对吗?customer 2是UITableViewCell中的文本,我在方法中使用void not iAction,并通过[tbcel addTarget:self action:@selector(pushView1:)forControlEvents:UIControlEventTouchUpInside]调用它;我需要的是,当我点击带有文本“customer 2”(我从库中单独添加)的自定义单元格时,点击该单元格时,应推送/显示一个新视图。
 (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath
 {
    NSLog(“Selected Row %d”, indexPath.row);
    YourNextViewController *objVC = (YourNextViewController *)[storyboard instantiateViewControllerWithIdentifier:@"ViewControllerIdentifier"];
   [self presentViewController: objVC animated:YES completion:nil];
 }