Skip to content

Commit

Permalink
Fix bugs
Browse files Browse the repository at this point in the history
Signed-off-by: wangmchn <[email protected]>
  • Loading branch information
wangmchn committed Apr 29, 2016
1 parent b1fefb9 commit 088b74a
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 8 deletions.
4 changes: 2 additions & 2 deletions WMPageController-Swift.podspec
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Pod::Spec.new do |s|
s.name = "WMPageController-Swift"
s.version = "1.2.4"
s.version = "1.3.2"
s.summary = "An easy solution to page controllers like NetEase News.(Swift Implementation)"
s.homepage = "https://github.com/wangmchn/WMPageController-Swift"
s.license = 'MIT (LICENSE)'
s.author = { "wangmchn" => "[email protected]" }
s.source = { :git => "https://github.com/wangmchn/WMPageController-Swift.git", :tag => "1.2.4" }
s.source = { :git => "https://github.com/wangmchn/WMPageController-Swift.git", :tag => "1.3.2" }
s.platform = :ios, '8.0'

s.source_files = 'PageController', 'PageController/**/*.{swift}'
Expand Down
1 change: 1 addition & 0 deletions WMPageController-Swift.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,7 @@
4D45BF6D1CC7BC12003F0151 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
Expand Down
Binary file not shown.
2 changes: 1 addition & 1 deletion WMPageController-Swift/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
// Override point for customization after application launch.
let pageController = customedPageController()
window?.rootViewController = UINavigationController(rootViewController: pageController)
reloadPageController(pageController, afterDelay: 5.0)
// reloadPageController(pageController, afterDelay: 5.0)
// updatePageController(pageController, title: "hahahahaha", afterDelay: 5.0)
return true
}
Expand Down
20 changes: 15 additions & 5 deletions WMPageController-Swift/PageController/PageController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ public class PageController: UIViewController, UIScrollViewDelegate, MenuViewDel
super.viewDidLoad()
view.backgroundColor = .whiteColor()
guard childControllersCount > 0 else { return }

calculateSize()
addScrollView()
addViewControllerAtIndex(_selectedIndex)
Expand Down Expand Up @@ -306,13 +307,18 @@ public class PageController: UIViewController, UIScrollViewDelegate, MenuViewDel

private func calculateSize() {
var navBarHeight = (navigationController != nil) ? CGRectGetMaxY(navigationController!.navigationBar.frame) : 0
let tabBar = tabBarController?.tabBar ?? (navigationController?.toolbar ?? nil)
let height = (tabBar != nil && tabBar?.hidden != true) ? CGRectGetHeight(tabBar!.frame) : 0
var tabBarHeight = (hidesBottomBarWhenPushed == true) ? 0 : height

if edgesForExtendedLayout == UIRectEdge.None {
navBarHeight = 0
tabBarHeight = 0
}

if viewFrame == CGRectZero {
viewWidth = view.frame.size.width
viewHeight = view.frame.size.height - menuHeight - navBarHeight
viewHeight = view.frame.size.height - menuHeight - navBarHeight - tabBarHeight
} else {
viewWidth = viewFrame.size.width
viewHeight = viewFrame.size.height - menuHeight
Expand Down Expand Up @@ -342,7 +348,8 @@ public class PageController: UIViewController, UIScrollViewDelegate, MenuViewDel
}

private func addMenuView() {
let menuViewFrame = CGRect(x: viewX, y: viewY, width: viewWidth, height: menuHeight)
let menuY = showOnNavigationBar ? 0 : viewY
let menuViewFrame = CGRect(x: viewX, y: menuY, width: viewWidth, height: menuHeight)
let menu = MenuView(frame: menuViewFrame)
menu.delegate = self
menu.dataSource = self
Expand Down Expand Up @@ -429,7 +436,7 @@ public class PageController: UIViewController, UIScrollViewDelegate, MenuViewDel
viewController.setValue(values?[index], forKey: optionalKeys[index])
}
addChildViewController(viewController)
viewController.view.frame = childViewFrames[index]
viewController.view.frame = childViewFrames.count > 0 ? childViewFrames[index] : view.frame
viewController.didMoveToParentViewController(self)
contentView?.addSubview(viewController.view)
willEnterController(viewController, atIndex: index)
Expand Down Expand Up @@ -486,6 +493,8 @@ public class PageController: UIViewController, UIScrollViewDelegate, MenuViewDel
private func adjustMenuViewFrame() {
var realMenuHeight = menuHeight
var menuX = viewX
var menuY = viewY

var rightWidth: CGFloat = 0.0
if showOnNavigationBar && (navigationController?.navigationBar != nil) {
for subview in (navigationController?.navigationBar.subviews)! {
Expand All @@ -506,15 +515,16 @@ public class PageController: UIViewController, UIScrollViewDelegate, MenuViewDel
}
let naviHeight = CGRectGetHeight(navigationController!.navigationBar.frame)
realMenuHeight = menuHeight > naviHeight ? naviHeight : realMenuHeight
menuY = 0
}
let menuWidth = viewWidth - menuX - rightWidth
menuView?.frame = CGRect(x: menuX, y: viewY, width: menuWidth, height: realMenuHeight)
menuView?.frame = CGRect(x: menuX, y: menuY, width: menuWidth, height: realMenuHeight)
menuView?.resetFrames()
}

// MARK: - UIScrollView Delegate
public func scrollViewDidScroll(scrollView: UIScrollView) {
if shouldNotScroll { return }
if shouldNotScroll || !hasInit { return }

layoutChildViewControllers()
guard startDragging else { return }
Expand Down

0 comments on commit 088b74a

Please sign in to comment.