में ज़ूम कैसे करें CustomCollectionViewLayout
के साथ कोड काम कर रहा है, और अंदर a lot of small cells
है लेकिन उपयोगकर्ता zoom
के बिना उन्हें नहीं देख सकता है। इसके अलावा सभी कोशिकाओं का चयन करने योग्य।UICollectionView
मैं ज़ूम सुविधा के अंदर अपना संग्रह दृश्य जोड़ना चाहता हूं!
नीचे दिए गए मेरे स्पष्ट कोड।
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)
}
}
इसके अलावा तहत नीचे आप वहाँ देख सकते हैं मेरी UICollectionView
लेआउट गुणों मैं maxZoom 4
चयनित लेकिन doesnt
किसी भी कार्रवाई की है!
धन्यवाद!
यह प्रश्न सहायक हो सकता है: [संग्रहदृश्य ज़ूम करने योग्य बनाएं] (http://stackoverflow.com/questions/13485617/make-uicollectionview-zoomable) – jojoT
@jojoT ty लेकिन वह नमूना obj-c और प्रत्येक आइटम चुटकी ज़ूम कर रहा है I तेजी से और क्षेत्र ज़ूम चाहते हैं प्रत्येक आइटम सरल ज़ूम – SwiftDeveloper
उपयोगकर्ता संग्रह दृश्य को छूता है, तो सेल ज़ूम हो जाता है? क्या आपका मतलब है, स्पर्श के बाद, पूरा संग्रह दृश्य धुंधला हो जाता है और स्पर्श कक्ष केवल देखने योग्य चौड़ाई और ऊंचाई पर स्क्रीन का केंद्र दिखाई देता है? –