Ich habe uicollectionview
Codes mit CustomCollectionViewLayout
, und innerhalb haben a lot of small cells
, aber Benutzer kann sie ohne nicht sehen. Auch alle Zellen wählbar.Zoomen in UICollectionView
Ich möchte meine Sammlung Ansicht in Zoom-Funktion hinzufügen!
Meine eindeutigen Codes unten.
class CustomCollectionViewController: UICollectionViewController {
var items = [Item]()
override func viewDidLoad() {
super.viewDidLoad()
customCollectionViewLayout.delegate = self
getDataFromServer()
}
func getDataFromServer() {
HttpManager.getRequest(url, parameter: .None) { [weak self] (responseData, errorMessage) ->() in
guard let strongSelf = self else { return }
guard let responseData = responseData else {
print("Get request error \(errorMessage)")
return
}
guard let customCollectionViewLayout = strongSelf.collectionView?.collectionViewLayout as? CustomCollectionViewLayout else { return }
strongSelf.items = responseData
customCollectionViewLayout.dataSourceDidUpdate = true
NSOperationQueue.mainQueue().addOperationWithBlock({() -> Void in
strongSelf.collectionView!.reloadData()
})
}
}
}
extension CustomCollectionViewController {
override func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int {
return items.count
}
override func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return items[section].services.count + 1
}
override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier(reuseIdentifier, forIndexPath: indexPath) as! CustomCollectionViewCell
cell.label.text = items[indexPath.section].base
return cell
}
override func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath cellForItemAtIndexPath: NSIndexPath) {
print(items[cellForItemAtIndexPath.section].base)
}
}
auch unter meine UICollectionView
Layouteigenschaften unterhalb Sie es sehen können ausgewählt i maxZoom 4
aber doesnt
haben keine Aktion!
Vielen Dank!
Diese Frage kann hilfreich sein: [make collectionview zoomable] (http://stackoverflow.com/questions/13485617/make-uicollectionview-zoomable) – jojoT
@jojoT ty aber dieses Beispiel obj-c und tun Pinch Zoom jedes Element i will schnell und Fläche Zoom nicht jedes Element einfach zoom – SwiftDeveloper
ist der Benutzer berührt die Sammlung anzeigen, dann die Zelle bekommen Zoom? Meinst du, nach der Berührung wird die Ansicht der ganzen Sammlung verschwommen und die berührte Zelle erscheint nur in der Mitte des Bildschirms in sichtbarer Breite und Höhe? –