millmany / mmcardview Goto Github PK
View Code? Open in Web Editor NEWCusom CollectionView card layout
License: MIT License
Cusom CollectionView card layout
License: MIT License
This application is modifying the autolayout engine from a background thread after the engine was accessed from the main thread. This can lead to engine corruption and weird crashes.
I have tried to setup a section header using UICollectionReusableView. but, it is not showing up.
Is there any way to achieve a section header with this library?
When we change the orientation, the cards don't resize properly. Can u please add this feature?
Thanks.
Hi,
Thank you for sharing the card view it looks very good. I'm having trouble to get the example working (I'm using Materials as well) card view is not showing. I did try to isolate and see if it is related to the cell, but if i just show the cell they will show in view. I'm doing it without storyboard. I'm not sure if i would be the cause of the problem. Only the first few lines of the code from example I changed just so that I can figure out why its not showing. However, I still couldn't figure out. It looks like objects were initiated under the card view, but the card view is not showing.
var card = CardView(frame: CGRect(x: 100, y: 200, width: 500, height: 500))
open override func viewDidLoad() {
super.viewDidLoad()
self.card.frame = CGRect(x: 100, y: 200, width: 500, height: 500)
self.card.backgroundColor = UIColor.red
view.addSubview(self.card)
self.card.cardDataSource = self
self.card.registerCardCell(c: CardACell.classForCoder(), nib: UINib.init(nibName: "CardACell", bundle: Bundle.main))
prepareToolbar()
let arr = self.generateCardInfo(cardCount: 10)
self.card.set(cards: arr)
self.card.showStyle(style: .cover)
//view.layout(card).horizontally().center()
view.backgroundColor = UIColor.purple
}
We are trying to display images from network in cell items. Our images were blinking simultaneously when scrolling MMCollectionView.
NumberOfItemsInSection method is keep calling when scroll the items. Why this is happening?
Pls suggest to solve this issue asap.
Thanks
I altered some things in your example ViewController.swift to give you the perspective I'm facing, those were the changes:
var titleArray = ["GIOVANNIJ","MARCO","IBITCI","GOD","DID","RUAN","APPEND","BIAJ","LELE","TETE"]
func generateCardInfo (cardCount:Int) -> [AnyObject] {
var arr = [AnyObject]()
let xibName = ["CardA"]//,"CardB","CardC"]
for _ in 1...cardCount {
let value = Int(arc4random_uniform(UInt32(xibName.count)))
arr.append(xibName[value] as AnyObject)
}
return arr
}
func cardView(collectionView:UICollectionView,item:AnyObject,indexPath:IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: item as! String, for: indexPath )
switch cell {
case let c as CardACell:
c.txtView.text = "Hello This is MMCardView ,Its a demo with different Card Type,This is a text type"
c.labTitle.text = titleArray[indexPath.row]
case let c as CardBCell:
let v = Int(arc4random_uniform(5))+1
c.imgV.image = UIImage.init(named: "image\(v)")
case let c as CardCCell:
c.clickCallBack {
if let vc = UIStoryboard.init(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "Second") as? SecondViewController {
vc.delegate = self
self.card.presentViewController(to: vc)
}
}
default:
return UICollectionViewCell()
}
return cell
}
@IBAction func filterAction () {
let sheet = UIAlertController.init(title: "Filter", message: "Select you want to show in View", preferredStyle: .alert)
sheet.addTextField(configurationHandler: nil)
let byText = UIAlertAction(title: "Filter by text", style: .default, handler: {
(alert: UIAlertAction!) -> Void in
self.card.filterAllDataWith(isInclued: { (idex, obj) -> Bool in
let titleTxt = self.titleArray[idex]
return titleTxt.lowercased().contains(sheet.textFields![0].text!)
})
})
/*let cellA = UIAlertAction(title: "CellA", style: .default, handler: {
(alert: UIAlertAction!) -> Void in
self.card.filterAllDataWith(isInclued: { (idex, obj) -> Bool in
return (obj as! String) == "CardA"
})
})
let cellB = UIAlertAction(title: "CellB", style: .default, handler: {
(alert: UIAlertAction!) -> Void in
self.card.filterAllDataWith(isInclued: { (idex, obj) -> Bool in
return (obj as! String) == "CardB"
})
})
let cellC = UIAlertAction(title: "CellC", style: .default, handler: {
(alert: UIAlertAction!) -> Void in
self.card.filterAllDataWith(isInclued: { (idex, obj) -> Bool in
return (obj as! String) == "CardC"
})
})
let ac = ["CardA","CardC"]
let cellAC = UIAlertAction(title: "CellA,CellC", style: .default, handler: {
(alert: UIAlertAction!) -> Void in
self.card.filterAllDataWith(isInclued: { (idex, obj) -> Bool in
return ac.contains(obj as! String)
})
})*/
let allCell = UIAlertAction(title: "Show all cells", style: .default, handler: {
(alert: UIAlertAction!) -> Void in
self.card.showAllData()
})
let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: {
(alert: UIAlertAction!) -> Void in
})
//sheet.addAction(cellA)
sheet.addAction(byText)
/*sheet.addAction(cellB)
sheet.addAction(cellC)
sheet.addAction(cellAC)*/
sheet.addAction(allCell)
sheet.addAction(cancelAction)
self.present(sheet, animated: true, completion: nil)
}
Now this is what I'm facing:
Can you help me with this?
Is there an API or a best practice to override default card height? The UI I have in mind is one that mimics Apple pay where cards are smaller.
Thanks,
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.