我不知道爲什麼,但當鍵盤出現時,它將我的細胞推出屏幕。我正在收集視圖中工作,以編程方式呈現我的視圖。這是我得到的錯誤,當發生這種情況:鍵盤將我的細胞推出屏幕
的UICollectionViewFlowLayout的行爲沒有定義的,因爲: 2017年8月21日13:09:19.710 audibleAPP [19038:1975381]的項目高度必須小於UICollectionView的高度減去頂部和底部值的頂部和底部值,減去內容頂部和底部值的頂部和底部值。
而這個代碼我有什麼
的AppDelegate
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
window = UIWindow(frame: UIScreen.main.bounds)
window?.makeKeyAndVisible()
let layout: UICollectionViewFlowLayout = {
let layout = UICollectionViewFlowLayout()
layout.scrollDirection = .horizontal
return layout
}()
let mainView = MainVC(collectionViewLayout: layout)
window?.rootViewController = mainView
return true
}
MainController
override func viewDidLoad() {
super.viewDidLoad()
collectionView?.backgroundColor = .blue
collectionView?.delegate = self
collectionView?.dataSource = self
collectionView?.isPagingEnabled = true
collectionView?.register(PageCell.self, forCellWithReuseIdentifier: reuseIdentifier)
collectionView?.register(LoginCell.self, forCellWithReuseIdentifier: loginIdentifier)
我並沒有把所有的代碼,因爲實在是太多了,我試圖把我認爲是錯誤的地方。
Here is a picture of the simulator, the red view is all the cell:
我已經嘗試過,並沒有工作。我把它放在viewDidLoad –
嘗試設置estimatedItemSize –
也不管用,我真的不知道會是什麼。 –