LibraryViewController.m 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. //
  2. // LibraryViewController.m
  3. //
  4. //
  5. // Created by Alexi on 3/11/14.
  6. // Copyright (c) 2014 Harman. All rights reserved.
  7. //
  8. #import "LibraryViewController.h"
  9. #import "UIView+Layout.h"
  10. #import "UIView+CustomAutoLayout.h"
  11. @interface LibraryViewController ()
  12. @end
  13. @implementation LibraryViewController
  14. - (void)configParams
  15. {
  16. self.libraryPages = [NSMutableArray array];
  17. }
  18. - (NSArray *)menuTitles
  19. {
  20. return nil;
  21. }
  22. - (void)addOwnViews
  23. {
  24. _libraryScrollView = [[LibraryScrollView alloc] init];
  25. _libraryScrollView.clipsToBounds = YES;
  26. _libraryScrollView.pageScrollDelegate = self;
  27. [self.view addSubview:_libraryScrollView];
  28. _navigationPanel = [[LibraryNavigationPanel alloc] initWith:[self menuTitles]];
  29. self.navigationItem.titleView = _navigationPanel;
  30. }
  31. - (void)configOwnViews
  32. {
  33. self.navigationPanel.delegate = self;
  34. [self.navigationPanel select:0];
  35. }
  36. #define kNaviTitleHeight 44
  37. - (void)layoutOnIPhone
  38. {
  39. CGRect rect = self.view.bounds;
  40. [_navigationPanel sizeWith:CGSizeMake(rect.size.width - 60 * 2, kNaviTitleHeight)];
  41. [_navigationPanel layoutParentHorizontalCenter];
  42. [_navigationPanel relayoutFrameOfSubViews];
  43. CGRect libPageRect = rect;
  44. if (_libraryScrollView.pages.count == 0)
  45. {
  46. [_libraryScrollView setFrameAndLayout:libPageRect withPages:self.libraryPages];
  47. }
  48. else
  49. {
  50. [_libraryScrollView setFrameAndLayout:libPageRect];
  51. }
  52. }
  53. #pragma mark -
  54. #pragma LibraryNavigationPanelDelegate Method
  55. - (void)onLibraryNavigationPanel:(LibraryNavigationPanel *)panel navigateTo:(NSInteger)index
  56. {
  57. [self.libraryScrollView scrollTo:index];
  58. }
  59. - (void)onPageScrollView:(PageScrollView *)pageView scrollToPage:(NSInteger)pageIndex
  60. {
  61. [_navigationPanel select:pageIndex];
  62. }
  63. @end