Skip to content

Commit

Permalink
fix position of calling reloadData()
Browse files Browse the repository at this point in the history
  • Loading branch information
Kazuhiro Hayashi committed Feb 26, 2018
1 parent bab9156 commit 6d49e62
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 11 deletions.
5 changes: 1 addition & 4 deletions iOS Sample/iOS Sample/AlignmentViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,7 @@ class AlignmentViewController: UIViewController {
menuViewController.menuView.cellAlignment = .left
}

menuViewController.view.alpha = 0
menuViewController.reloadData(with: nil) { [weak self] (finish) in
self?.menuViewController.view.alpha = 1
}
menuViewController.reloadData()
}

private func makeDataSource() -> [(menu: String, content: UIViewController)] {
Expand Down
13 changes: 10 additions & 3 deletions iOS Sample/iOS Sample/SimpleViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,24 @@ class SimpleViewController: UIViewController {
let vc = UIStoryboard(name: "ContentTableViewController", bundle: nil).instantiateInitialViewController() as! ContentTableViewController
return (menu: title, content: vc)
}

lazy var firstLoad: (() -> Void)? = { [weak self, menuViewController, contentViewController] in
menuViewController?.reloadData()
contentViewController?.reloadData()
self?.firstLoad = nil
}

override func viewDidLoad() {
super.viewDidLoad()

menuViewController?.register(type: TitleLabelMenuViewCell.self, forCellWithReuseIdentifier: "identifier")
menuViewController?.registerFocusView(view: UnderlineFocusView())

menuViewController?.reloadData()
contentViewController?.reloadData()

}
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
firstLoad?()
}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
Expand Down
14 changes: 12 additions & 2 deletions iOS Sample/iOS Sample/TwoLineMenuViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,23 @@ class TwoLineMenuViewController: UIViewController {
return (menu: $0, content: vc)
}


lazy var firstLoad: (() -> Void)? = { [weak self, menuViewController, contentViewController] in
menuViewController?.reloadData()
contentViewController?.reloadData()
self?.firstLoad = nil
}

override func viewDidLoad() {
super.viewDidLoad()

menuViewController?.register(nib: UINib(nibName: "TwoLineMenuCell", bundle: nil), forCellWithReuseIdentifier: "identifier")
menuViewController?.registerFocusView(view: UnderlineFocusView())
menuViewController?.reloadData()
contentViewController?.reloadData()
}

override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
firstLoad?()
}

override func didReceiveMemoryWarning() {
Expand Down
13 changes: 11 additions & 2 deletions iOS Sample/iOS Sample/ViewInsertedViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,28 @@ class ViewInsertedViewController: UIViewController {
return (menu: title, content: vc)
}

lazy var firstLoad: (() -> Void)? = { [weak self, menuViewController, contentViewController] in
menuViewController?.reloadData()
contentViewController?.reloadData()
self?.firstLoad = nil
}

override func viewDidLoad() {
super.viewDidLoad()

menuViewController?.register(type: TitleLabelMenuViewCell.self, forCellWithReuseIdentifier: "identifier")
menuViewController?.registerFocusView(view: UnderlineFocusView())
menuViewController?.reloadData()
contentViewController?.reloadData()
}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}

override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
firstLoad?()
}

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if let vc = segue.destination as? PagingMenuViewController {
menuViewController = vc
Expand Down

0 comments on commit 6d49e62

Please sign in to comment.