ios - 如何快速从 Storyboard中的 didSelectRowAt indexPath 打开 View 选项卡 Controller ?

标签 ios swift uitableview uitabbarcontroller

我有一个带有 tabbarcontroller 的 Storyboard。其中一个选项卡栏有一个表格 View ,我希望当用户从表格 View 中点击一行时,打开一个带有另一个选项卡栏的详细 View 。 问题是当我打开详细 View 标签栏时隐藏。如何在 didselectrowatindexpath 中显示标签栏?

didselectrowatindexpath中的代码:

   func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        let storybaord=UIStoryboard(name: "Main", bundle: nil)
        let DVC=storybaord.instantiateViewController(withIdentifier: "NewsViewController") as! NewsViewController
        DVC.getImage=sneaker[indexPath.row]
        DVC.getNews=News[indexPath.row]
        self.navigationController?.pushViewController(DVC, animated: true)

    }

我已经创建了单 View 应用程序。我已经创建了 DiscoveryNewsTableViewCell。我用两个数组 1-运动鞋 2- 新闻数组填充了表格 View 单元格。我想要特定的数组显示栏 Controller 的 ist 选项卡。但我确实得到了这些标签栏 Controller 第一个选项卡上的字段。这是此 https://drive.google.com/file/d/1uSYl-4a1UQXpMXkSQ_l8aij6EH_v2yna/view?usp=sharing 的示例代码

最佳答案

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
// setting these values in local storage using user defaults
    let currentObj = News[indexPath.row]
    UserDefaults.standard.set(currentObj, forKey: "currentOb")
    let storybaord=UIStoryboard(name: "Main", bundle: nil)
    let DVC=storybaord.instantiateViewController(withIdentifier: "NewsViewController") as! NewsViewController
    self.navigationController?.pushViewController(DVC, animated: true)
    }

关于ios - 如何快速从 Storyboard中的 didSelectRowAt indexPath 打开 View 选项卡 Controller ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47919254/

相关文章:

iOS 单元测试实例变量

ios - 在swift中过滤字典

ios - hidesBottomBarWhenPushed 使 UITabBar "jump"

javascript - jQuery 选择菜单更改功能在 iPhone 上不起作用

swift - 如何在 Swift 中制作经过身份验证的 HTTPS 帖子?

ios - 如何在 Swift 的 maintableviewcell 中访问内部 tableviewcell 的高度

objective-c - 根据内容在 UITableViewCell 中调整 UIWebView 的大小

ios - 将 indexPath.row 发送到另一个 UIViewController

ios 表数据不显示

ios - 动画背景 UIImage