Привет! При нажатии на text field контент смещается автоматически. Раньше такого не было, насколько я помню. Как я могу убрать это? Гугл не помог ;(
Автоматическое смещение контента
stormway
#3
В таком случае, честно говоря, даже не знаю, где искать причину. Может ли это быть как-то связано с UICollectionViewDelegateFlowLayout?
Вот так выглядит мой контроллер:
import UIKit
class CardsCollectionViewController: UICollectionViewController, UICollectionViewDelegateFlowLayout {
override func viewDidLoad() {
super.viewDidLoad()
}
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
let screenSize = UIScreen.main.bounds
let screenWidth = screenSize.width
let screenHeight = screenSize.height
let cellWidth = screenWidth - 100
let cellHeight = screenHeight - 250
return CGSize(width: cellWidth, height: cellHeight)
}
override func numberOfSections(in collectionView: UICollectionView) -> Int {
return 1
}
override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 5
}
override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
var cell = UICollectionViewCell()
switch indexPath.row {
case 0:
let nib = UINib(nibName: "PostsCollectionViewCell", bundle: nil)
self.collectionView?.register(nib, forCellWithReuseIdentifier: "Post")
cell = collectionView.dequeueReusableCell(withReuseIdentifier: "Post", for: indexPath) as! PostsCollectionViewCell
return cell
case 1:
let nib = UINib(nibName: "CommentsCollectionViewCell", bundle: nil)
self.collectionView?.register(nib, forCellWithReuseIdentifier: "Comments")
cell = collectionView.dequeueReusableCell(withReuseIdentifier: "Comments", for: indexPath) as! CommentsCollectionViewCell
case 2:
let nib = UINib(nibName: "UsersCollectionViewCell", bundle: nil)
self.collectionView?.register(nib, forCellWithReuseIdentifier: "Users")
cell = collectionView.dequeueReusableCell(withReuseIdentifier: "Users", for: indexPath) as! UsersCollectionViewCell
case 3:
let nib = UINib(nibName: "PhotosCollectionViewCell", bundle: nil)
self.collectionView?.register(nib, forCellWithReuseIdentifier: "Photos")
cell = collectionView.dequeueReusableCell(withReuseIdentifier: "Photos", for: indexPath) as! PhotosCollectionViewCell
case 4:
let nib = UINib(nibName: "TodosCollectionViewCell", bundle: nil)
self.collectionView?.register(nib, forCellWithReuseIdentifier: "Todos")
cell = collectionView.dequeueReusableCell(withReuseIdentifier: "Todos", for: indexPath) as! TodosCollectionViewCell
default:
break
}
return cell
}
}