redribben

.m

Jan 17th, 2015
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. #import "ViewController.h"
  3.  
  4. @interface ViewController ()
  5.  
  6. @property (weak, nonatomic) IBOutlet UIScrollView *scrollViewForAccordian;
  7. @property (weak, nonatomic) IBOutlet UIView* mainView;
  8.  
  9. @end
  10.  
  11. @implementation ViewController
  12.  
  13. @synthesize scrollViewForAccordian;
  14. @synthesize mainView;
  15.  
  16. - (void)viewDidLoad {
  17.     [super viewDidLoad];
  18.    
  19.    /*
  20.     NSLayoutConstraint *widthConstraint = [NSLayoutConstraint constraintWithItem:self.mainView
  21.                                                                        attribute:NSLayoutAttributeWidth
  22.                                                                        relatedBy:NSLayoutRelationEqual
  23.                                                                           toItem:scrollViewForAccordian
  24.                                                                        attribute:NSLayoutAttributeWidth
  25.                                                                       multiplier:1.0
  26.                                                                         constant:0];
  27.    
  28.     NSLayoutConstraint *heightConstraint = [NSLayoutConstraint constraintWithItem:self.mainView
  29.                                                                        attribute:NSLayoutAttributeHeight
  30.                                                                        relatedBy:NSLayoutRelationEqual
  31.                                                                           toItem:scrollViewForAccordian
  32.                                                                        attribute:NSLayoutAttributeHeight
  33.                                                                       multiplier:1.0
  34.                                                                         constant:0];
  35. */
  36.     NSLayoutConstraint *rightConstraint = [NSLayoutConstraint constraintWithItem:self.mainView
  37.                                                                        attribute:NSLayoutAttributeLeft
  38.                                                                        relatedBy:NSLayoutRelationEqual
  39.                                                                           toItem:scrollViewForAccordian
  40.                                                                        attribute:NSLayoutAttributeLeft
  41.                                                                       multiplier:1.0
  42.                                                                         constant:0];
  43.    
  44.     NSLayoutConstraint *bottomConstraint = [NSLayoutConstraint constraintWithItem:self.mainView
  45.                                                                        attribute:NSLayoutAttributeBottom
  46.                                                                        relatedBy:NSLayoutRelationEqual
  47.                                                                           toItem:scrollViewForAccordian
  48.                                                                        attribute:NSLayoutAttributeBottom
  49.                                                                       multiplier:1.0
  50.                                                                         constant:0];
  51.    
  52.     NSLayoutConstraint *leftConstraint = [NSLayoutConstraint constraintWithItem:self.mainView
  53.                                                                        attribute:NSLayoutAttributeRight
  54.                                                                        relatedBy:NSLayoutRelationEqual
  55.                                                                           toItem:scrollViewForAccordian
  56.                                                                        attribute:NSLayoutAttributeRight
  57.                                                                       multiplier:1.0
  58.                                                                         constant:0];
  59.    
  60.     NSLayoutConstraint *topConstraint = [NSLayoutConstraint constraintWithItem:self.mainView
  61.                                                                        attribute:NSLayoutAttributeTop
  62.                                                                        relatedBy:NSLayoutRelationEqual
  63.                                                                           toItem:scrollViewForAccordian
  64.                                                                        attribute:NSLayoutAttributeTop
  65.                                                                       multiplier:1.0
  66.                                                                         constant:0];
  67.    
  68.     scrollViewForAccordian.translatesAutoresizingMaskIntoConstraints = NO;
  69.  
  70.     [mainView addConstraints:@[leftConstraint, bottomConstraint, topConstraint, rightConstraint]];
  71.    
  72.     scrollViewForAccordian.backgroundColor = [UIColor redColor];
  73.  
  74.    
  75.    
  76.    
  77.    
  78. //    [self makeCell];
  79. }
  80.  
  81. - (void)viewWillAppear:(BOOL)animated {
  82.     [self.mainView addSubview:self.scrollViewForAccordian];
  83.     NSLog(@"RIGHTHERE %@", NSStringFromCGRect(self.scrollViewForAccordian.frame));
  84. }
  85.  
  86. - (void)makeCell {
  87.     //Making the Cell
  88.     UIView *viewForOutertable = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ([[ UIScreen mainScreen ] bounds].size.width), 44)];
  89.     viewForOutertable.translatesAutoresizingMaskIntoConstraints = NO;
  90.     NSDictionary *viewsDictionary = @{@"Cell":viewForOutertable};
  91.    
  92. /*    NSLayoutConstraint *horizontalConstraint = [NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[myCell]-0-|"
  93.                                                                     options:0
  94.                                                                     metrics:nil
  95.                                                                       views:viewsDictionary];
  96.     [viewForOutertable addConstraint:horizontalConstraint];
  97. */
  98.  
  99.     //Setting the buttons
  100.     UIButton *buttonToEnlarge = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, ([[ UIScreen mainScreen ] bounds].size.width) , 44)];
  101.     [buttonToEnlarge setImage:[UIImage imageNamed:@"ltgrey.jpg"]
  102.                      forState:UIControlStateNormal];
  103.    
  104.     [buttonToEnlarge setImage:[UIImage imageNamed:@"grey.jpg"]
  105.                      forState:UIControlStateSelected];
  106.     [buttonToEnlarge addTarget:self
  107.                         action:@selector(expandButtonTapped:)
  108.               forControlEvents: UIControlEventTouchUpInside];
  109.  
  110.     [viewForOutertable addSubview:buttonToEnlarge];
  111.     scrollViewForAccordian.backgroundColor = [UIColor redColor];
  112.     [scrollViewForAccordian addSubview:viewForOutertable];
  113.    
  114. }
  115.  
  116. -(void)expandButtonTapped:(UIButton *)sender {
  117.     NSLog(@"Button Clicked");
  118. }
  119.  
  120. - (void)didReceiveMemoryWarning {
  121.     [super didReceiveMemoryWarning];
  122.     // Dispose of any resources that can be recreated.
  123. }
  124.  
  125. @end
Advertisement
Add Comment
Please, Sign In to add comment