func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
if collectionView.tag == 2{
switch indexPath.item {
case 0:
if let vc = storyboard?.instantiateViewController(withIdentifier: "offersScreen") as? OffersVC {
vc.cityID = self.cityID!
vc.categoryID = indexPath.item + 1
vc.headingLBL.text = self.names[indexPath.item]
vc.cityLBL.text = self.selectCity.text!
present(vc, animated: true, completion: nil)
}
case 1:
print("You're heading VC 1!")
case 2:
print("You're heading VC 2!")
case 3:
print("You're heading VC 3!")
default:
print("Something went wrong")
}
}
}
我把一切都写了完美的idk我弄错了。目前发现零值。我从标签栏viewController呈现viewcontroller具有4个值请帮助或指导。预先感谢。
原因是所有出口都为零,直到vc加载为止
选项#1
vc.loadViewIfNeeded()
vc.headingLBL.text = self.names[indexPath.item]
选项#2
制作需要发送的内容
class OffersVC:UIViewController {
var sendedStr = ""
然后在viewDidLoad
内
self.headingLBL = sendedStr
[查看您的图像描述,我认为问题是您试图在不首先对其进行初始化的情况下展开'headingLBL'。