- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个问题。
我需要帮助。我一直在寻找解决方案大约 5 个小时。不幸的是没有成功。
我的问题是我有几个 Storyboard并且没有使用 Segue 创建。
我希望将选定的 Tableviewcell 标题传递给 rootViewController。
这是我在 ModalViewTable 中的代码:
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath){
let indexNumber = "\(indexPath.row)"
let indexPath = tableView.indexPathForSelectedRow
let currentCell = tableView.cellForRow(at: indexPath!) as UITableViewCell!
let storyboard = UIStoryboard(name: "addTime", bundle: nil)
var viewController = storyboard.instantiateViewController(withIdentifier: "addTimeVC") as! addTimeViewController
viewController.test = "TESTABCDEF"
passedValue = ("\(indexNumber)")
dismiss(animated: true, completion: nil)
}
我的 firstViewController 中有一个属性 test
。这里有什么问题?我也尝试过委托(delegate)和闭包,但没有成功。请帮我。
最佳答案
试试这个:
let indexNumber = "\(indexPath.row)"
let indexPath = tableView.indexPathForSelectedRow
let currentCell = tableView.cellForRow(at: indexPath!) as UITableViewCell!
let viewController = navigationController!.presentingViewController as! addTimeViewController
viewController.test = "TESTABCDEF"
passedValue = ("\(indexNumber)")
navigationController!.dismiss(animated: true, completion: nil)
当您使用 present(_:animated)
方法以模态方式呈现 View Controller 时,呈现 的 View Controller 具有 presentingViewController
属性设置为呈现它的 View Controller 。换句话说,此属性包含对先前 View Controller 的引用。
关于ios - 使用 Swift 3 将数据从 Modal Viewcontroller 传递到 rootController(不要 Segue),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43792315/
我想将字符串传递给作为 rootController.view 的 subview 添加的 label.text: @implementation MainViewController //the r
我正在尝试创建一个 iPad 应用程序,其用户界面与 Apple 的邮件应用程序类似,即: RootView Controller ( TableView )位于 Split View的左侧,用于通过
是否可以在基于导航的应用程序的 RootController 上调整 UITableView 的大小?当 RootViewController.xib 在 IB 中打开时,没有 View 。只是 UI
我的问题是从 Controller (恰好是我的 rootViewController)获取信息到另一个 View 。在尝试通过应用程序委托(delegate)访问它时,我无法让它工作。我已经找到了如
在以下情况下使用 UINavigationController 的代码是什么? 基础应用程序基于 XCode 4 模板“Utility Application”,具有 MainView 和 FlipS
如果我将 View 平台 Controller 设置为 AppDelegate 窗口的根 Controller ,则当应用程序在 iPad 上以横向启动时,中心 View 将以其纵向大小显示,而不是调
我有以下 Storyboard: 如果用户导航到 View A1-2,然后选择选项卡 B,然后选择选项卡 A ... 他们将看到 TableViewController A1-2(他们最近的“选项卡
我有一个问题。 我需要帮助。我一直在寻找解决方案大约 5 个小时。不幸的是没有成功。 我的问题是我有几个 Storyboard并且没有使用 Segue 创建。 我希望将选定的 Tableviewcel
我想在我的 TB 应用程序中将所有异常记录到日志文件中。因此,我尝试像往常一样使用自定义 sys.excepthook。但是仍然会引发每个异常并且不会记录任何内容。这是我的代码: class Root
我是一名优秀的程序员,十分优秀!