Skip to content

Commit

Permalink
fix memery bug
Browse files Browse the repository at this point in the history
  • Loading branch information
DuckDeck committed Sep 22, 2017
1 parent b9d1def commit 780481c
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 51 deletions.
1 change: 0 additions & 1 deletion GrandMenu/GrandBaseTable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@ class GrandBaseTable: UITableView,UIGestureRecognizerDelegate {
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
return true
}

}
12 changes: 0 additions & 12 deletions GrandMenu/GrandCellTableViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,4 @@ class GrandCellTableViewCell: UITableViewCell {
}
}
}

override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}

override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)

// Configure the view for the selected state
}

}
3 changes: 1 addition & 2 deletions GrandMenu/GrandContentViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ class GrandContentViewController: UIViewController,UITableViewDataSource,UITable
super.viewDidLoad()
tableView = UITableView()
tableView.dataSource = self
tableView.delegate = self

tableView.delegate = self
view.addSubview(tableView)
}
override func viewWillLayoutSubviews() {
Expand Down
24 changes: 1 addition & 23 deletions GrandMenu/GrandMenuTable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ open class GrandMenuTable: UIView {
}
}

fileprivate var parentViewController:UIViewController?
weak fileprivate var parentViewController:UIViewController?
fileprivate var childViewController:[UIViewController]?
fileprivate var collectionView:UICollectionView?
fileprivate var startOffsetX:CGFloat = 0.0
Expand Down Expand Up @@ -92,28 +92,6 @@ 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
// }

}

public func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
Expand Down
9 changes: 2 additions & 7 deletions GrandMenu/GrandPageContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import UIKit
class GrandPageContentView: UIView {
let cellId = "GrandCelId"

open var delegate:GrandPageContentViewDelagate?
weak open var delegate:GrandPageContentViewDelagate?
open var contentViewCurrentIndex = 0{
didSet{
if contentViewCurrentIndex < 0 || contentViewCurrentIndex > self.childViewController!.count-1{
Expand All @@ -34,7 +34,7 @@ class GrandPageContentView: UIView {
}
}

fileprivate var parentViewController:UIViewController?
weak fileprivate var parentViewController:UIViewController?
fileprivate var childViewController:[UIViewController]?
fileprivate var collectionView:UICollectionView?
fileprivate var startOffsetX:CGFloat = 0.0
Expand Down Expand Up @@ -64,7 +64,6 @@ class GrandPageContentView: UIView {
}

addSubview(self.collectionView!)

}


Expand Down Expand Up @@ -121,7 +120,6 @@ extension GrandPageContentView:UICollectionViewDataSource,UICollectionViewDelega
endIndex = startIndex - 1
endIndex = endIndex < 0 ? 0 : endIndex
}

delegate?.contentViewDidScroll?(contentview: self, startIndex: startIndex, endIndex: endIndex, progress: progress)
}

Expand All @@ -133,7 +131,4 @@ extension GrandPageContentView:UICollectionViewDataSource,UICollectionViewDelega
delegate?.contentViewDidEndDecelerating?(contentview: self, startIndex: startIndex, endIndex: endIndex)
}




}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ class ViewControllerDemoViewController: UIViewController {
navigationItem.rightBarButtonItems?.append(btn2)
grandMenu = GrandMenu(frame:CGRect(x: 0, y: 64, width: UIScreen.main.bounds.size.width, height: 40) , titles: ["First","Second","Third","FouthFouthFouth","Fifth","1","2","Thir333333d","Fo44uth","7"])
grandMenu?.backgroundColor = UIColor.white
grandMenu?.selectMenu = scrollCallback
grandMenu?.selectMenu = {[weak self](item:GrandMenuItem, index:Int) in
self?.grandMenuTable?.contentViewCurrentIndex = index
}
grandMenu?.itemColor = UIColor.green
grandMenu?.itemFont = 14
grandMenu?.itemSelectedFont = 18
Expand Down Expand Up @@ -70,10 +72,7 @@ class ViewControllerDemoViewController: UIViewController {
}



func scrollCallback(_ item:GrandMenuItem, index:Int){
grandMenuTable?.contentViewCurrentIndex = index
}

func changeColor(){
let index = Int(arc4random()) % colors.count
grandMenu?.itemSeletedColor = colors[index]
Expand Down
2 changes: 1 addition & 1 deletion GrandMenuDemo/GrandMenuDemo/ViewDemoViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ class ViewDemoViewController: UIViewController,UITableViewDelegate,UITableViewDa
}

func scrollViewDidScroll(_ scrollView: UIScrollView) {
print("big scroll + \(scrollView.contentOffset.y)")
let bottomCellOffset = tb.rect(forSection: 1).origin.y - 64
if scrollView.contentOffset.y >= bottomCellOffset {
scrollView.contentOffset = CGPoint(x: 0, y: bottomCellOffset)
Expand All @@ -132,6 +131,7 @@ class ViewDemoViewController: UIViewController,UITableViewDelegate,UITableViewDa
}
deinit {
NotificationCenter.default.removeObserver(self)
print("123")
}
}

Expand Down

0 comments on commit 780481c

Please sign in to comment.