diff --git a/WMPageController-Swift.podspec b/WMPageController-Swift.podspec index 986c309..f9c7bac 100755 --- a/WMPageController-Swift.podspec +++ b/WMPageController-Swift.podspec @@ -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" => "wangmchn@163.com" } - 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}' diff --git a/WMPageController-Swift.xcodeproj/project.pbxproj b/WMPageController-Swift.xcodeproj/project.pbxproj index b06bd1e..5d8deca 100644 --- a/WMPageController-Swift.xcodeproj/project.pbxproj +++ b/WMPageController-Swift.xcodeproj/project.pbxproj @@ -697,6 +697,7 @@ 4D45BF6D1CC7BC12003F0151 /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; diff --git a/WMPageController-Swift.xcodeproj/project.xcworkspace/xcuserdata/Mark.xcuserdatad/UserInterfaceState.xcuserstate b/WMPageController-Swift.xcodeproj/project.xcworkspace/xcuserdata/Mark.xcuserdatad/UserInterfaceState.xcuserstate index 1302704..745d3ee 100644 Binary files a/WMPageController-Swift.xcodeproj/project.xcworkspace/xcuserdata/Mark.xcuserdatad/UserInterfaceState.xcuserstate and b/WMPageController-Swift.xcodeproj/project.xcworkspace/xcuserdata/Mark.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/WMPageController-Swift/AppDelegate.swift b/WMPageController-Swift/AppDelegate.swift index 7ef1074..6cb639e 100644 --- a/WMPageController-Swift/AppDelegate.swift +++ b/WMPageController-Swift/AppDelegate.swift @@ -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 } diff --git a/WMPageController-Swift/PageController/PageController.swift b/WMPageController-Swift/PageController/PageController.swift index 16a8145..dadfc7f 100644 --- a/WMPageController-Swift/PageController/PageController.swift +++ b/WMPageController-Swift/PageController/PageController.swift @@ -140,6 +140,7 @@ public class PageController: UIViewController, UIScrollViewDelegate, MenuViewDel super.viewDidLoad() view.backgroundColor = .whiteColor() guard childControllersCount > 0 else { return } + calculateSize() addScrollView() addViewControllerAtIndex(_selectedIndex) @@ -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 @@ -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 @@ -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) @@ -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)! { @@ -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 }