Ho cercato di capire come posso far riempire la cella della larghezza, come puoi vedere nell'immagine la larghezza tra le celle è troppo grande. Sto usando una cella personalizzata con un solo imageView.UICollectionView Cella personalizzata per riempire la larghezza In Swift
ho cercato di personalizzarlo dallo storyboard, ma immagino che non esiste alcuna opzione per questo o dovrebbe essere fatto a livello di codice.
mia UICollectionViewController:
@IBOutlet var collectionView2: UICollectionView!
let recipeImages = ["angry_birds_cake", "creme_brelee", "egg_benedict", "full_breakfast", "green_tea", "ham_and_cheese_panini", "ham_and_egg_sandwich", "hamburger", "instant_noodle_with_egg.jpg", "japanese_noodle_with_pork", "mushroom_risotto", "noodle_with_bbq_pork", "starbucks_coffee", "thai_shrimp_cake", "vegetable_curry", "white_chocolate_donut"]
override func viewDidLoad() {
super.viewDidLoad()
// Uncomment the following line to preserve selection between presentations
// self.clearsSelectionOnViewWillAppear = false
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
override func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int {
//#warning Incomplete method implementation -- Return the number of sections
return 1
}
override func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
//#warning Incomplete method implementation -- Return the number of items in the section
return recipeImages.count
}
override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier(reuseIdentifier, forIndexPath: indexPath) as! RecipeCollectionViewCell
// Configure the cell
cell.recipeImageView.image = UIImage(named: recipeImages[indexPath.row])
return cell
}
Basta controllare questa risposta http://stackoverflow.com/questions/29649687/reduce-space-between-cells -in-a-collectionview/29649994 # 29649994 –
Qual è il contentResizingMode della visualizzazione dell'immagine? ... e stai usando il layout automatico? –
Ad esempio, in diverse dimensioni, ad esempio: 560 × 350, no non sto utilizzando alcun tipo di layout automatico. – AaoIi