Skip to content

Commit

Permalink
1.1.0 is ok
Browse files Browse the repository at this point in the history
  • Loading branch information
Stan Hu authored and Stan Hu committed Sep 21, 2017
1 parent 90f4e26 commit b9d1def
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 71 deletions.
4 changes: 2 additions & 2 deletions GrandMenu.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Pod::Spec.new do |s|
#

s.name = "GrandMenu"
s.version = "1.0.4"
s.version = "1.1.0"
s.summary = "GrandMenu is a powerful and simple Menu"

# This description is used to generate tags and improve search results.
Expand Down Expand Up @@ -80,7 +80,7 @@ Pod::Spec.new do |s|
# Supports git, hg, bzr, svn and HTTP.
#

s.source = { :git => "https://github.com/DuckDeck/GrandMenu.git", :tag => "1.0.4" }
s.source = { :git => "https://github.com/DuckDeck/GrandMenu.git", :tag => "1.1.0" }


# ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
Expand Down
2 changes: 1 addition & 1 deletion GrandMenu/GrandCellTableViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class GrandCellTableViewCell: UITableViewCell {
var cellCanScroll = false{
didSet{
for vc in vcs{
if let v = vc as? ContentViewController{
if let v = vc as? GrandContentViewController{
v.canScroll = cellCanScroll
v.tableView.contentOffset = CGPoint()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,29 @@

import UIKit

class ContentViewController: UIViewController,UITableViewDataSource,UITableViewDelegate {
class GrandContentViewController: UIViewController,UITableViewDataSource,UITableViewDelegate {
var canScroll = false;
var tableView = UITableView()
var fingerIsTouch = false
var arrData:[String]?

override func viewDidLoad() {
super.viewDidLoad()
tableView = UITableView()
tableView.dataSource = self
tableView.delegate = self
arrData = [String]()
for _ in 0...40
{
arrData?.append("Controller1")
}

view.addSubview(tableView)
}
override func viewWillLayoutSubviews() {
tableView.frame = self.view.bounds
}

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return arrData!.count
return 0
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cellIdentity = "vc1"
var cell = tableView.dequeueReusableCell(withIdentifier: cellIdentity)
if cell == nil{
cell = UITableViewCell(style: .default, reuseIdentifier: cellIdentity)
}
cell?.textLabel?.text = arrData![(indexPath as NSIndexPath).row]
return cell!
return UITableViewCell()
}


Expand Down
44 changes: 22 additions & 22 deletions GrandMenu/GrandMenuTable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,34 +92,34 @@ extension GrandMenuTable:UICollectionViewDataSource,UICollectionViewDelegate{
if isSelectBtn {
return
}
let scrollWidth = scrollView.bounds.size.width
let currentOffsetX = scrollView.contentOffset.x
let startIndex = floor(startOffsetX / scrollWidth)
var endIndex:CGFloat = 0
var progress:CGFloat = 0
if currentOffsetX > startOffsetX {
progress = (currentOffsetX - startOffsetX)/scrollWidth
endIndex = startOffsetX + 1
if endIndex > CGFloat(self.childViewController!.count - 1) {
endIndex = CGFloat(self.childViewController!.count - 1)
}
}
else if currentOffsetX == startOffsetX{
progress = 0.0
endIndex = startIndex
}
else{
progress = (startOffsetX - currentOffsetX)/scrollWidth
endIndex = startIndex - 1
endIndex = endIndex < 0 ? 0 : endIndex
}
// let scrollWidth = scrollView.bounds.size.width
// let currentOffsetX = scrollView.contentOffset.x
// let startIndex = floor(startOffsetX / scrollWidth)
// var endIndex:CGFloat = 0
// var progress:CGFloat = 0
// if currentOffsetX > startOffsetX {
// progress = (currentOffsetX - startOffsetX)/scrollWidth
// endIndex = startOffsetX + 1
// if endIndex > CGFloat(self.childViewController!.count - 1) {
// endIndex = CGFloat(self.childViewController!.count - 1)
// }
// }
// else if currentOffsetX == startOffsetX{
// progress = 0.0
// endIndex = startIndex
// }
// else{
// progress = (startOffsetX - currentOffsetX)/scrollWidth
// endIndex = startIndex - 1
// endIndex = endIndex < 0 ? 0 : endIndex
// }

}

public func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
let scrollViewWidth = scrollView.bounds.size.width
let currentOffsetX = scrollView.contentOffset.x
let startIndex = floor(startOffsetX / scrollViewWidth)
// let startIndex = floor(startOffsetX / scrollViewWidth)
let endIndex = floor(currentOffsetX / scrollViewWidth)
if let block = scrollToIndex {
block(Int(endIndex))
Expand Down
8 changes: 4 additions & 4 deletions GrandMenuDemo/GrandMenuDemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
AE7B84851CB258AB00F375AD /* ViewDemoViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE7B84841CB258AB00F375AD /* ViewDemoViewController.swift */; };
AE99792D1F73C1D7009A5A03 /* GrandCellTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE9979261F73C1D7009A5A03 /* GrandCellTableViewCell.swift */; };
AE99792E1F73C1D7009A5A03 /* GrandPageContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE9979271F73C1D7009A5A03 /* GrandPageContentView.swift */; };
AE99792F1F73C1D7009A5A03 /* ContentViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE9979281F73C1D7009A5A03 /* ContentViewController.swift */; };
AE99792F1F73C1D7009A5A03 /* GrandContentViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE9979281F73C1D7009A5A03 /* GrandContentViewController.swift */; };
AE9979321F73C1D7009A5A03 /* GrandMenuTable.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE99792B1F73C1D7009A5A03 /* GrandMenuTable.swift */; };
AE9979331F73C1D7009A5A03 /* GrandBaseTable.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE99792C1F73C1D7009A5A03 /* GrandBaseTable.swift */; };
AEFF8D7B1F73E9AB002E1AE6 /* ScollViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AEFF8D7A1F73E9AB002E1AE6 /* ScollViewController.swift */; };
Expand All @@ -52,7 +52,7 @@
AE7B84841CB258AB00F375AD /* ViewDemoViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ViewDemoViewController.swift; sourceTree = "<group>"; };
AE9979261F73C1D7009A5A03 /* GrandCellTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GrandCellTableViewCell.swift; sourceTree = "<group>"; };
AE9979271F73C1D7009A5A03 /* GrandPageContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GrandPageContentView.swift; sourceTree = "<group>"; };
AE9979281F73C1D7009A5A03 /* ContentViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentViewController.swift; sourceTree = "<group>"; };
AE9979281F73C1D7009A5A03 /* GrandContentViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GrandContentViewController.swift; sourceTree = "<group>"; };
AE99792B1F73C1D7009A5A03 /* GrandMenuTable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GrandMenuTable.swift; sourceTree = "<group>"; };
AE99792C1F73C1D7009A5A03 /* GrandBaseTable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GrandBaseTable.swift; sourceTree = "<group>"; };
AEFF8D7A1F73E9AB002E1AE6 /* ScollViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScollViewController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -105,7 +105,7 @@
A205AA821C488F0E0043F5F6 /* GrandMenu */ = {
isa = PBXGroup;
children = (
AE9979281F73C1D7009A5A03 /* ContentViewController.swift */,
AE9979281F73C1D7009A5A03 /* GrandContentViewController.swift */,
AE99792C1F73C1D7009A5A03 /* GrandBaseTable.swift */,
AE9979261F73C1D7009A5A03 /* GrandCellTableViewCell.swift */,
AE9979271F73C1D7009A5A03 /* GrandPageContentView.swift */,
Expand Down Expand Up @@ -228,7 +228,7 @@
A205AA8F1C4893020043F5F6 /* Controller1.swift in Sources */,
AE7B84831CB258A200F375AD /* ViewControllerDemoViewController.swift in Sources */,
AE9979331F73C1D7009A5A03 /* GrandBaseTable.swift in Sources */,
AE99792F1F73C1D7009A5A03 /* ContentViewController.swift in Sources */,
AE99792F1F73C1D7009A5A03 /* GrandContentViewController.swift in Sources */,
A205AA901C4893020043F5F6 /* Controller2.swift in Sources */,
A205AA861C488F8D0043F5F6 /* GrandMenuItem.swift in Sources */,
AE99792D1F73C1D7009A5A03 /* GrandCellTableViewCell.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,32 @@

import UIKit

class ScollViewController: UIViewController {
class ScollViewController: GrandContentViewController {

// var arrData:[String]?
//
// override func viewDidLoad() {
// super.viewDidLoad()
// arrData = [String]()
// for i in 0...40
// {
// arrData?.append("Controller\(i)")
// }
// }
//
// override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// return arrData!.count
// }
//
// override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
// let cellIdentity = "vc1"
// var cell = tableView.dequeueReusableCell(withIdentifier: cellIdentity)
// if cell == nil{
// cell = UITableViewCell(style: .default, reuseIdentifier: cellIdentity)
// }
// cell?.textLabel?.text = arrData![(indexPath as NSIndexPath).row]
// return cell!
// }
var arrData:[String]?

override func viewDidLoad() {
super.viewDidLoad()
arrData = [String]()
tableView.tableFooterView = UIView()
for i in 0...40
{
arrData?.append("Controller\(i)")
}
}

override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return arrData!.count
}

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cellIdentity = "vc1"
var cell = tableView.dequeueReusableCell(withIdentifier: cellIdentity)
if cell == nil{
cell = UITableViewCell(style: .default, reuseIdentifier: cellIdentity)
}
cell?.textLabel?.text = arrData![(indexPath as NSIndexPath).row]
return cell!
}

}
4 changes: 2 additions & 2 deletions GrandMenuDemo/GrandMenuDemo/ViewDemoViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ class ViewDemoViewController: UIViewController,UITableViewDelegate,UITableViewDa
if contentCell == nil {
contentCell = GrandCellTableViewCell(style: .default, reuseIdentifier: "cell2")
let titles = ["全部","游戏","汽车","电影","京东"]
var vcs = [ContentViewController]()
var vcs = [ScollViewController]()
for t in titles{
let vc = ContentViewController()
let vc = ScollViewController()
vc.title = t
vcs.append(vc)
}
Expand Down

0 comments on commit b9d1def

Please sign in to comment.