Advertisement
Guest User

Untitled

a guest
Sep 2nd, 2014
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. override func viewDidLoad() {
  2. super.viewDidLoad();
  3.  
  4. // 1) Create the three views used in the swipe container view
  5. var BVc :BViewController = BViewController(nibName: "BViewController", bundle: nil);
  6. var AVc :AViewController = AViewController(nibName: "AViewController", bundle: nil);
  7.  
  8. var CVc :CViewController = CViewController(nibName: "CViewController", bundle: nil);
  9.  
  10.  
  11. // 2) Add in each view to the container view hierarchy
  12. // Add them in opposite order since the view hieracrhy is a stack
  13.  
  14.  
  15. self.addChildViewController(BVc);
  16. self.scrollView!.addSubview(BVc.view);
  17. BVc.didMoveToParentViewController(self);
  18.  
  19. self.addChildViewController(AVc);
  20. self.scrollView!.addSubview(AVc.view);
  21. AVc.didMoveToParentViewController(self);
  22.  
  23. self.addChildViewController(CVc);
  24. self.scrollView!.addSubview(CVc.view);
  25. CVc.didMoveToParentViewController(self);
  26.  
  27.  
  28. // 3) Set up the frames of the view controllers to align
  29. // with eachother inside the container view
  30.  
  31. var BFrame :CGRect = BVc.view.frame;
  32. BFrame.origin.x = 2*BFrame.width;
  33. CVc.view.frame = BFrame;
  34.  
  35. var adminFrame :CGRect = AVc.view.frame;
  36. adminFrame.origin.x = adminFrame.width;
  37. BVc.view.frame = adminFrame;
  38.  
  39.  
  40.  
  41.  
  42. // 4) Finally set the size of the scroll view that contains the frames
  43. var scrollWidth: CGFloat = 3 * self.view.frame.width
  44. var scrollHeight: CGFloat = self.view.frame.size.height
  45. self.scrollView!.contentSize = CGSizeMake(scrollWidth, scrollHeight);
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement