Questions tagged «flowlayout»

3
如何设置UICollectionViewDelegateFlowLayout?
UIViewController维护对UICollectionView的引用。控制器应使用UICollectionViewDelegateFlowLayout修改内置流布局。 将视图的数据源设置为self很容易: MyViewController.m - (void)viewDidLoad { self.collectionView.dataSource = self; } 但是,如何将控制器设置为视图的委托流布局? - (void)viewDidLoad { self.collectionView.dataSource= self; // self.collectionView.??? = self; } 我试过了: - (void)viewDidLoad { self.collectionView.dataSource= self; self.collectionView.collectionViewLayout = self; } 但是我得到了错误:“分配不兼容的指针类型...”。 集合头文件如下所示: MyViewController.h @interface MyViewController : UIViewController <UICollectionViewDataSource, UICollectionViewDelegateFlowLayout>

14
Swift:如何在设备旋转后刷新UICollectionView布局
我使用UICollectionView(flowlayout)构建简单的布局。每个单元格的宽度设置为使用self.view.frame.width 但是当我旋转设备时,单元格不会更新。 我找到了一个函数,该函数在方向改变时被调用: override func willRotateToInterfaceOrientation(toInterfaceOrientation: UIInterfaceOrientation, duration: NSTimeInterval) { //code } 但我找不到更新UICollectionView布局的方法 主要代码在这里: 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 …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.