gpt4 book ai didi

uiviewcontroller - 在自定义单元格中点击 UIButton 后显示新的 ViewController

转载 作者:可可西里 更新时间:2023-11-01 00:53:46 25 4
gpt4 key购买 nike

嘿嘿!

我想显示一个带有 Action 的 ViewController(自定义单元格中 UIButton 的 tappedInside)。在这种情况下,我不能仅通过控制从自定义单元格中的 UIButton 拖动到 NavigationController(嵌入了 ViewController)。

我如何才能意识到 tableview 一行中按钮(在自定义单元格中)上的“tappedInside”会显示一个新的 ViewController?

谢谢!

最佳答案

您可以在单击具有委托(delegate)的单元格时触发:

func tableView(tableView: UITableView!, didSelectRowAtIndexPath indexPath: NSIndexPath!) {
// some code
}

要打开一个新的 View Controller ,如果你使用 Storyboard,你可以试试这个:

let storyboard = UIStoryboard(name: "Main", bundle: nil)
let newVC = storyboard.instantiateViewControllerWithIdentifier("myIdentifier") as youClassController
self.presentViewController(newVC, animated: false, completion: nil)

希望对你有帮助

关于uiviewcontroller - 在自定义单元格中点击 UIButton 后显示新的 ViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25634593/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com