Swift: Как обновить макет UicollectionView после вращения устройстваIOS

Программируем под IOS
Ответить
Anonymous
 Swift: Как обновить макет UicollectionView после вращения устройства

Сообщение Anonymous »

Я использовал uicollectionView (flowlayout) для создания простой макет. src = "https://i.sstatic.net/yrtxh.jpg" /> < /p>

Я нашел функцию, которая вызывается при изменении ориентации: < /p>

override func willRotateToInterfaceOrientation(toInterfaceOrientation:
UIInterfaceOrientation, duration: NSTimeInterval) {
//code
}
< /code>

Но я не могу найти способ обновить макет UicollectionView < /p>

Основной код здесь: < /p>

class ViewController: UIViewController , UICollectionViewDelegate , UICollectionViewDataSource , UICollectionViewDelegateFlowLayout{

@IBOutlet weak var myCollection: UICollectionView!

var numOfItemsInSecOne: Int!
override func viewDidLoad() {
super.viewDidLoad()

numOfItemsInSecOne = 8
// Do any additional setup after loading the view, typically from a nib.
}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}

override func willRotateToInterfaceOrientation(toInterfaceOrientation: UIInterfaceOrientation, duration: NSTimeInterval) {

//print("orientation Changed")
}

func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int {
return 1
}

func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return numOfItemsInSecOne
}

func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("cellO", forIndexPath: indexPath)

return cell
}

func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize{
let itemSize = CGSize(width: self.view.frame.width, height: 100)
return itemSize
}}


Подробнее здесь: https://stackoverflow.com/questions/368 ... the-device
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «IOS»