{"id":15561303,"url":"https://github.com/magi82/mggridview","last_synced_at":"2025-09-15T08:25:52.504Z","repository":{"id":56920468,"uuid":"95334389","full_name":"magi82/MGGridView","owner":"magi82","description":"MGGridView is a grid view created by a combination of collection views.","archived":false,"fork":false,"pushed_at":"2017-06-25T17:09:12.000Z","size":5491,"stargazers_count":25,"open_issues_count":0,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-25T11:04:19.912Z","etag":null,"topics":["collectionview","gridview","ios","swift3"],"latest_commit_sha":null,"homepage":"https://magi82.github.io","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/magi82.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-06-25T02:44:52.000Z","updated_at":"2019-12-19T17:00:43.000Z","dependencies_parsed_at":"2022-08-21T04:20:25.018Z","dependency_job_id":null,"html_url":"https://github.com/magi82/MGGridView","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magi82%2FMGGridView","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magi82%2FMGGridView/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magi82%2FMGGridView/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magi82%2FMGGridView/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/magi82","download_url":"https://codeload.github.com/magi82/MGGridView/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250526061,"owners_count":21445124,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["collectionview","gridview","ios","swift3"],"created_at":"2024-10-02T16:07:19.951Z","updated_at":"2025-04-23T22:29:40.029Z","avatar_url":"https://github.com/magi82.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MGGridView\n\n![Swift](https://img.shields.io/badge/Swift-3.0-orange.svg)\n[![Platform](https://img.shields.io/cocoapods/p/MGGridView.svg?style=flat)](http://cocoapods.org/pods/MGGridView)\n[![Version](https://img.shields.io/cocoapods/v/MGGridView.svg?style=flat)](http://cocoapods.org/pods/MGGridView)\n[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n[![License](https://img.shields.io/cocoapods/l/MGGridView.svg?style=flat)](http://cocoapods.org/pods/MGGridView)\n\nMGGridView is a grid view created by a combination of collection views.\u003cbr\u003e\nApple's collection view method is simple and easy to implement. :sunny:\n\nMGGridView can be created in the storyboard.\u003cbr\u003e\nIn Carthage, however, it is programmatically only.\u003cbr\u003e\n[Carthage Issues #763](https://github.com/Carthage/Carthage/issues/763)\n\nThe column cell does not support registration in the storyboard.\u003cbr\u003e\nYou can implement it programmatically or with xib.\n\n## Sample\n\n\u003cimg src=\"https://github.com/magi82/MGGridView/blob/master/Resources/sample.gif?raw=true\" width=\"240\"\u003e\n\n\n## Usage\n- Declare the MGGridView, and add the data to the data source.\n\n```swift\nvar gridView: MGGridView? = nil\nlet menus: [[String]] = [\n    [\"1-1\", \"1-2\", \"1-3\", \"1-4\", \"1-5\", \"1-6\", \"1-7\", \"1-8\", \"1-9\", \"1-10\"],\n    [\"2-1\", \"2-2\", \"2-3\", \"2-4\", \"2-5\", \"2-6\", \"2-7\", \"2-8\", \"2-9\", \"2-10\"],\n    [\"3-1\", \"3-2\", \"3-3\", \"3-4\", \"3-5\", \"3-6\", \"3-7\", \"3-8\", \"3-9\", \"3-10\"],\n    [\"4-1\", \"4-2\", \"4-3\", \"4-4\", \"4-5\", \"4-6\", \"4-7\", \"4-8\", \"4-9\", \"4-10\"],\n    [\"5-1\", \"5-2\", \"5-3\", \"5-4\", \"5-5\", \"5-6\", \"5-7\", \"5-8\", \"5-9\", \"5-10\"],\n    [\"6-1\", \"6-2\", \"6-3\", \"6-4\", \"6-5\", \"6-6\", \"6-7\", \"6-8\", \"6-9\", \"6-10\"],\n    [\"7-1\", \"7-2\", \"7-3\", \"7-4\", \"7-5\", \"7-6\", \"7-7\", \"7-8\", \"7-9\", \"7-10\"],\n    [\"8-1\", \"8-2\", \"8-3\", \"8-4\", \"8-5\", \"8-6\", \"8-7\", \"8-8\", \"8-9\", \"8-10\"],\n    [\"9-1\", \"9-2\", \"9-3\", \"9-4\", \"9-5\", \"9-6\", \"9-7\", \"9-8\", \"9-9\", \"9-10\"]\n  ]\n```\n\n- Create an MGGridView and configure.\n\n```swift\ngridView = MGGridView(frame: UIScreen.main.bounds,\n                      collectionViewLayout: UICollectionViewFlowLayout())\nif let grid = gridView {\n  grid.backgroundColor = .white\n  grid.register(MGGridViewCell.self,\n                    forCellWithReuseIdentifier: \"row\")\n  grid.configure(delegate: self)\n  self.view.addSubview(grid)\n}\n```\n\n- Implement a data source and delegate for MGGridView.\u003cbr\u003e\n  You can do the same as the collection view.\n- **Important!!!!** Here's what's important.\u003cbr\u003e\n  You need to config for the column in the grid view.\n  \n```swift\n// Implementing delegate and data source\nextension ViewController: MGGridViewDelegate, MGGridViewDataSource {\n  func gridView(_ gridView: UICollectionView,\n                cellForItemAt indexPath: IndexPath) -\u003e UICollectionViewCell {\n    let cell = gridView.dequeueReusableCell(withReuseIdentifier: \"row\",\n                                            for: indexPath) as! MGGridViewCell\n    \n    // Important!! You need to configure for column.\n    cell.configure { view, layout in\n      layout.scrollDirection = .horizontal\n      \n      view.showsHorizontalScrollIndicator = false\n      view.showsVerticalScrollIndicator = false\n      view.register(UICollectionViewCell.self,\n                    forCellWithReuseIdentifier: \"column\")\n    }\n    \n    return cell\n  }\n  \n  func gridView(_ gridView: UICollectionView,\n                numberOfItemsInSection section: Int) -\u003e Int {\n    return menus.count\n  }\n}\n```\n\n- If necessary, also implement a Layout delegate.\n\n```swift\n// Row layout delegate implementation\nextension ViewController: MGGridViewDelegateFlowLayout {\n  func gridView(_ gridView: UICollectionView,\n                layout gridViewLayout: UICollectionViewLayout,\n                sizeForItemAt indexPath: IndexPath) -\u003e CGSize {\n    return CGSize(width: UIScreen.main.bounds.width, height: 100)\n  }\n}\n```\n\n- Implements a delegate for the column cell of MGGridView.\n- **Important!!!!** Here's what's important.\u003cbr\u003e\n  In a delegate implementation, collectionView.tag is the row index of the corresponding grid view.\n\n```swift\n// Delegate implementation for column\nextension ViewController: UICollectionViewDelegate, UICollectionViewDataSource {\n  func collectionView(_ collectionView: UICollectionView,\n                      numberOfItemsInSection section: Int) -\u003e Int {\n    // Tag is the row index of the grid view.\n    return menus[collectionView.tag].count\n  }\n  \n  func collectionView(_ collectionView: UICollectionView,\n                      cellForItemAt indexPath: IndexPath) -\u003e UICollectionViewCell {\n    let cell = collectionView.dequeueReusableCell(withReuseIdentifier: \"column\",\n                                                  for: indexPath) as! ColumnCollectionViewCell\n    \n    cell.title.text = menus[collectionView.tag][indexPath.row]\n    return cell\n  }\n}\n```\n\n- You can also implement the Layout delegate as needed.\n\n```swift\n// Row layout delegate implementation\nextension ViewController: UICollectionViewDelegateFlowLayout {\n  func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -\u003e CGSize {\n    return CGSize(width: 80, height: 80)\n  }\n}\n```\n\n## Aid\n\n- [tiny2n](https://github.com/tiny2n)\n\n## Requirements\n\n- Swift 3.0+\n- Xcode 8.0+\n- iOS 8.0+\n\n## Installation\n\n- **For iOS 8+ projects** with [CocoaPods](https://cocoapods.org):\n\n```ruby\npod 'MGGridView', '~\u003e 0.1.1'\n```\n\n- **For iOS 8+ projects** with [Carthage](https://github.com/Carthage/Carthage):\n\n```ruby\ngithub \"magi82/MGGridView ~\u003e 0.1.1\"\n```\n\n## Author\n\nmagi82, bkhwang82@gmail.com\n\n## License\n\n**MGGridView** is available under the MIT license. See the [LICENSE](LICENSE) file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagi82%2Fmggridview","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmagi82%2Fmggridview","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagi82%2Fmggridview/lists"}