重新加载后,uicollectionviewcell标签未对齐
我试过以下代码在屏幕上呈现简单集合视图。 但contentview中的子视图不能正确保存
我在Swift 2.3中用Xcode 7.3.1编码 这是怎么回事?
下面是代码
import Foundation
class CustomerOverdueViewController : BaseViewController , UICollectionViewDelegateFlowLayout {
@IBOutlet weak var collectionView: UICollectionView!
@IBOutlet weak var tableView: UITableView!
@IBOutlet weak var lblTotalOverdue: UILabel!
@IBOutlet weak var lblInvestedFunds: UILabel!
@IBOutlet weak var segmentedControl: UISegmentedControl!
var rangeArray = NSArray()
var selectedOverdueIndex = 0
var selectedColor = UIColor()
override func viewDidLoad() {
super.viewDidLoad()
self.title = "Customer Overdue"
}
@IBAction func segValueChanged(sender: UISegmentedControl) {
}
func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int {
return 1
}
func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 6
}
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let reuseIdentifier = String("CustomerOverdueCollectionViewCell")
let cell = collectionView.dequeueReusableCellWithReuseIdentifier(reuseIdentifier, forIndexPath: indexPath) as! CustomerOverdueCollectionViewCell
return cell
}
func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath){
}
func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize
{
return CGSize(width: collectionView.frame.size.width/2 - 10, height: collectionView.frame.size.height/3 - 10)
}
func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAtIndex section: Int) -> UIEdgeInsets
{
return UIEdgeInsets(top: 5, left: 5, bottom: 0, right: 5)
}
func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAtIndex section: Int) -> CGFloat
{
return 10.0
}
func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAtIndex section: Int) -> CGFloat
{
return 10.0
}
}
您使用自动布局还是自动调整? – Vinodh
我正在使用自动布局 – Anik
我认为你在contraview中有冲突解决它们你将能够得到deisred output.Please张贴初始图像,看起来整齐,然后重新加载 – Vinodh