gpt4 book ai didi

ios - 点击 UITableView 的单元格,其他 View 不会出现

转载 作者:行者123 更新时间:2023-11-30 12:49:08 26 4
gpt4 key购买 nike

我有一个包含一些搜索结果的 tableView。我已将第一个和第二个 View 与“ Storyboard Segue”从单元格连接到第二个 View 。

这是第一个ViewController中编写的代码:

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {

let indexPath = self.tableProva.indexPathForSelectedRow?.row

let vc = segue.destination as! DettaglioNewViewController

vc.titleLibro = posts[indexPath!].name
vc.authorLibro = posts[indexPath!].author
vc.ISBNLibro = posts[indexPath!].ISBN

}

在其他项目中它工作得很好,但在这个项目中它不起作用,要显示第二个 viewController,我必须点击并向右或向左滑动。

看来问题是图形化的。如果我尝试单击单元格不会变成灰色。如果我长时间按住它就会变成灰色

其他人也遇到过这种情况吗?

有人可以帮助我吗?

最佳答案

您应该使用“didSelectRowAtIndexPath”方法来转至特定单元格的不同 View 。使用......

var storyboard: UIStoryboard = UIStoryboard(name: "Main", bundle: NSBundle(forClass: self.dynamicType))

vc = storyboard.instantiateViewControllerWithIdentifier("LoginVC") as DettaglioNewViewController
vc.loadView()

..... 寻找所需的信息。

*信息示例*

func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath)
{
myFavIndex = indexPath.row
let storyBoard = UIStoryboard(name: "Main", bundle:nil)
let view = storyBoard.instantiateViewControllerWithIdentifier("LoginVC") as! DettaglioNewViewController
view.imageURL = self.imageArray[mySelectedIndex]
view.titleString = self.titleArray[mySelectedIndex]
self.presentViewController(view, animated: true, completion: nil)
}

在上面的示例中,我使用新的 View Controller 图像和标题作为 view.imageURLview.titleString 来填充我选择的单元格信息中的 View 元素通过[mySelectedIndex]。您应该能够使用 IntUIImageString 来完成此操作,例如

关于ios - 点击 UITableView 的单元格,其他 View 不会出现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41230088/

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