redribben

trying to stretch width

Jan 13th, 2015
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #import "ViewController.h"
  2.  
  3. @interface ViewController ()
  4.  
  5. @property (weak, nonatomic) IBOutlet UIScrollView *scrollViewForAccordian;
  6.  
  7. @end
  8.  
  9. @implementation ViewController
  10.  
  11. @synthesize scrollViewForAccordian;
  12.  
  13. - (void)viewDidLoad {
  14.     [super viewDidLoad];
  15.     [self makeCell];
  16. }
  17.  
  18. - (void)makeCell {
  19.     //Making the Cell
  20.     UIView *viewForOutertable = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ([[ UIScreen mainScreen ] bounds].size.width), 44)];
  21.     viewForOutertable.translatesAutoresizingMaskIntoConstraints = NO;
  22.     NSDictionary *viewsDictionary = @{@"Cell":viewForOutertable};
  23.    
  24.     NSArray *constraint_V = [NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[myCell]-0-|"
  25.                                                                     options:0
  26.                                                                     metrics:nil
  27.                                                                       views:viewsDictionary];
  28.     [viewForOutertable addConstraint:constraint_V];
  29.    
  30.  
  31.     //Setting the buttons
  32.     UIButton *buttonToEnlarge = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, ([[ UIScreen mainScreen ] bounds].size.width) , 44)];
  33.     [buttonToEnlarge setImage:[UIImage imageNamed:@"ltgrey.jpg"]
  34.                      forState:UIControlStateNormal];
  35.    
  36.     [buttonToEnlarge setImage:[UIImage imageNamed:@"grey.jpg"]
  37.                      forState:UIControlStateSelected];
  38.     [buttonToEnlarge addTarget:self
  39.                         action:@selector(expandButtonTapped:)
  40.               forControlEvents: UIControlEventTouchUpInside];
  41.  
  42.     [viewForOutertable addSubview:buttonToEnlarge];
  43.    
  44.     [scrollViewForAccordian addSubview:viewForOutertable];
  45.    
  46. }
  47.  
  48. -(void)expandButtonTapped:(UIButton *)sender {
  49.     NSLog(@"Button Clicked");
  50. }
  51.  
  52. - (void)didReceiveMemoryWarning {
  53.     [super didReceiveMemoryWarning];
  54.     // Dispose of any resources that can be recreated.
  55. }
  56.  
  57. @end
Advertisement
Add Comment
Please, Sign In to add comment