我有uicollectionview
代碼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
有任何動作!
謝謝!
這個問題可能會有所幫助:[製作的CollectionView縮放(http://stackoverflow.com/questions/13485617/make-uicollectionview-zoomable) – jojoT
@jojoT TY但樣品OBJ-C和做雙指縮放每個項目我想要快速和區域縮放不是每個項目簡單縮放 – SwiftDeveloper
是用戶觸摸集合視圖,然後單元格變焦?你的意思是,觸摸後,整個收集視圖變得模糊,觸及單元格只出現在可視寬度和高度的屏幕中心? –