0
새로운보기를 확장 클릭, I ImageView가 있고 레이블이 적은 셀이있는 collectionView 이 있어야합니다.CollectionView 셀은 내가 처음의 ViewController 첫 번째 탭에서 TabBarViewController뿐만 아니라 4 개 탭 (스토리 보드에 4 개의 ViewControllers)</p> <p>이있는 데모 응용 프로그램을 만들려고 해요
셀을 클릭하면 전체 화면으로 확대되고보기가 여전히 탭 막대의 첫 번째 탭에 유지됩니다. 이제 ViewController 내부의보기 선택한 셀의 확대보기 인 새로운보기로 변경되었습니다. 아래로 스크롤하면 컬렉션보기가 계속되고 다른 셀을 클릭하여 확장 할 수 있습니다. 언제든지 ... 뒤로하고보기에서 펼쳐진 마지막 셀을 표시합니다.
나는 내가하려는 일에 대해 충분히 명확 해 졌으면 좋겠다. 지금은 병이 이미
import UIKit
class ViewController: UIViewController, UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout {
var imagesArray = []
var imageSizes = [CGSize]()
var labelsArray = [""]
var descArray = [""]
@IBOutlet weak var collectionView: UICollectionView!
override func viewDidLoad() {
super.viewDidLoad()
self.collectionView.delegate = self
self.collectionView.dataSource = self
for i in 0..<imagesArray.count {
let currImg = imagesArray[i]
let currHeight = currImg.size.height
let currSize = CGSize(width: 150, height: currHeight + 125)
imageSizes.append(currSize)
}
}
public func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return imagesArray.count
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "Cell", for: indexPath) as! CollectionVCe
cell.cellImg.image = imagesArray[indexPath.row]
cell.descLabel.text = descArray[1]
cell.itemLabel.text = labelsArray[0]
cell.cellImg.contentMode = .scaleAspectFill
cell.layer.cornerRadius = 9
cell.backgroundColor = UIColor.red
cell.cellImg.backgroundColor = UIColor.blue
return cell
}
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
return imageSizes[indexPath.row]
}
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets {
return UIEdgeInsetsMake(0, 25, 0, 25)
}
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat {
return 10
}
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
if let cell = collectionView.cellForItem(at: indexPath) {
cell.frame = collectionView.frame
}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
}
에 오신 것을 환영합니다 크기 대리자를 호출! 답을 나타내는 코드를 추가하십시오. –