swift - 从视图控制器对 tableview 控制器进行 segue
问题描述
当以编程方式在我的视图控制器中点击一个按钮时,我试图对表视图控制器进行 segue。这是我的代码:
@objc func editProfileButtonAction(sender: UIButton!) {
print("ButtonTapped")
func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if let identifier = segue.identifier {
if identifier == "EditProfile" {
var editProfileTableViewController = segue.destination as! EditProfileTableViewController
editProfileTableViewController = self
}
}
}
}
我真的可以使用一些帮助。我还需要使用同一视图控制器中的按钮对集合视图控制器进行 segue。
解决方案
好的澄清一下。无法以编程方式创建 segue。Segue 是情节提要上的箭头,用于从一个 VC 链接到另一个 VC。它们被称为:performSegue。这调用了函数准备。
如果你想在点击按钮时显示一个新的 VC(没有 segue),那么你在按钮函数中使用 present(VC(), animated: true, completion: nil) }。VC 以模态方式呈现。
@objc func editProfileButtonAction(sender: UIButton!) {
print("editProfileButtonAction")
present(EditProfileTableViewController(), animated: true, completion: nil)
}
推荐阅读
- flutter - 列表更改时动画容器没有动画
- java - 8 谜题 Java 算法谜题
- react-native - 识别命令的Android应用
- powershell - 方法调用失败,因为 [Sitecore.Data.Items.Item] 不包含名为“op_Addition”的方法
- java - 三重 Des 码返回不同长度的密码
- c# - 懒惰评估的属性语法差异
- android - Android 中的 PayPal 集成
- java - java.lang.ClassNotFoundException:在路径上找不到类“com.google.android.gms.measurement.AppMeasurementJobService”:DexPathList
- c++ - c++ curl undefined reference to _imp__curl_easy_init 代码块
- php - TYPO3 无法显示后端