私は、迅速かつイオスプログラミングを学ぶためにinstagramのようなアプリケーションをプログラミングしてきました。今度は、トップバーになるUIStackViewと、リクエストを送信してイメージを変更する3つのボトムボタンを作成しました。コレクションinstagram app swiftのようなポジショニングを表示
問題点 - 私はCollectionViewで位置、幅、セル間隔を設定できません。私がしたい: CollectionViewすべてのデバイス上の全幅画像間の セル間隔= 1 CollectionViewは、私は今、何をしなければならなかったの
上部バーと下部のボタンの完全な高さの間に配置すべきですか?私のエミュレータの
画面:私のストーリーボードのhttp://prntscr.com/d1mmu1
私はストーリーボードでこれを行う試みたと思いますが、parametresのすべてを変えていたが、hasntは私の目標を達しました。 同じ高さをCollectionViewとアプリケーションのメインビューに追加すると、すべての画面が表示され、スクロール後に消えます。 どのようにその位置と幅、高さ、およびセルの間隔を設定できますか?
here is a code of my viewcontroller for CollectionView -
// MARK: - UICollectionViewDataSourceプロトコル
// tell the collection view how many cells to make
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return self.items.count
}
// make a cell for each cell index path
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
// get a reference to our storyboard cell
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: reuseIdentifier, for: indexPath as IndexPath) as! MyCollectionViewCell
// Use the outlet in our custom class to get a reference to the UILabel in the cell
cell.imageView.image = UIImage(named: "main/p\(self.items[indexPath.item].code)/main/main.jpg")
print("main_card_images/p\(self.items[indexPath.item].code)/main/main")
return cell
}
// MARK: - UICollectionViewDelegate protocol
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
// handle tap events
print("You selected cell #\(indexPath.item)!")
print(self.items[indexPath.item])
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
let yourNextViewController = (segue.destination as! ViewControllerCard)
let indexPath = collectionView.indexPath(for: sender as! UICollectionViewCell)
yourNextViewController.mainCardImage = self.items[(indexPath?.item)!]
}
私の答えをチェックしhttp://stackoverflow.com/questions/40325327/adjust-cellsize-for-fit-all-screens/40325452#4 0325452 – Joe