选择表格视图后进行导航

| 我创建了类似于邮件应用程序的内容。 tableView(主视图),其中列出了API中的数据库内容以及顶部的搜索栏。 对于搜索,我将具有搜索响应的视图(第二个)放在最前面,然后将其放在另一个表视图中(第二个)。 对于这一部分,可以。 现在,我想要导航到另一个视图,但是当我使用\“ pushViewController:\”选择单元格时,没有追加任何内容(我在\“ main \” tableView中执行相同的操作,并且效果很好)。 我将第二个表视图链接到委托和数据源。 我在“第二”视图的.h中添加了“ UINavigationControllerDelegate”。 除了我的第二个导航之外,其他所有方法都运行良好。     
已邀请:
        在推送之前,检查第二个导航控制器是否为空:
  NSLog(@\" nav con is %@\", mySecondNavigationController);
    
        您只需要一个tableView即可进行搜索并显示所有数据。只需维护两个数组。第一个包含您的原始数据,第二个包含搜索的数据。作为搜索何时开始,请使用第二个数组重新加载tableView并将所有数据放入其中。这样,您的导航将适用于两种情况。 迅速:
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int
{
    if isSearch == \"true\"
    {
        return self.searchArray.count
    }
    else
    {
        return self.arr1.count
    }
}

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
{
    var cell:UITableViewCell? =
    tableView.dequeueReusableCellWithIdentifier(\"tableCell\") as? UITableViewCell

    if(cell == nil)
    {
        cell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: \"tableCell\")
        cell!.selectionStyle = UITableViewCellSelectionStyle.None
    }       
    if isSearch == \"true\"
    {
        var main_string = self.searchArray[indexPath.row]
        var attributedString = NSMutableAttributedString(string:main_string)
            attributedString.addAttribute(NSForegroundColorAttributeName, value: UIColor(red: 0.0/255.0, green: 168.0/255.0, blue: 255.0/255.0, alpha: 1.0) , range: NSMakeRange(0, string_to_color.length))
        name.attributedText = attributedString
    }
    else
    {
        name.text = self.arr1[indexPath.row] as String
    }
    return cell!
}
    

要回复问题请先登录注册