私はプログラム的コレクションビューを作り、設定プロパティmultipleSelectionOnデフォルト値で偽
を私のコレクションビューコードご覧ください:iOS Swift 3でインスタンスクラスのvalueプロパティを変更するには?
import UIKit
class GalleryCollectionViewController: UICollectionViewController , UICollectionViewDelegateFlowLayout {
open var multipleSelectionOn:Bool = false
override init(collectionViewLayout layout: UICollectionViewLayout) {
super.init(collectionViewLayout: layout)
collectionView?.collectionViewLayout = layout
collectionView!.register(GalleryCollectionViewCell.self, forCellWithReuseIdentifier: "cell")
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func viewDidLoad() {
super.viewDidLoad()
print(multipleSelectionOn)
}
**//AND SOME ANOTHER CODE**
}
そして、このようにそれを呼び出す:
let layout = UICollectionViewFlowLayout()
let galleryColVC = GalleryCollectionViewController(collectionViewLayout: layout)
galleryColVC.multipleSelectionOn = true
let galleryNav = UINavigationController(rootViewController: galleryColVC)
self.present(galleryNav, animated: true, completion: nil)
しかし変更を呼び出しコードのプロパティが設定されていないと私を示すだけ偽値。
これを修正するにはどうすればよいですか?
を? –
はいそれを変更してアクセスしたいです@UdayaSri –
self.present(galleryNav、animated:true、completion:nil)の後でtrueに設定してみてください。それは動作するはずです。 –