gpt4 book ai didi

ios - 具有不同类的 UIViewcontroller 的直接按钮

转载 作者:行者123 更新时间:2023-11-30 13:16:47 25 4
gpt4 key购买 nike

我有一个包含 10 多个不同按钮的 CollectionView。有没有一种方法可以根据按下的按钮更改 View Controller ?让我知道你的想法!如果有任何困惑,我会及时做出回应。

最佳答案

您可以使用 didSelectItemAtIndexPath 方法来检查哪个项目被按下,并根据行转到不同的 View 。

在此方法中:

func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) 

您可以通过检查indexPath.row来调用您的更改

switch indexPath.row {
case 0 :
//do changes for first button
case 1 :
//do changes for second button
...
case 9 :
//do changes for tenth button
default :
print("Error : button press wasn't handled")
}

关于ios - 具有不同类的 UIViewcontroller 的直接按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38136450/

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