Advertisement
Guest User

Untitled

a guest
Feb 9th, 2016
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. @interface ViewController : UITableViewController
  2. @end
  3.  
  4. @implementation ViewController
  5.  
  6. - (void)viewDidLoad
  7. {
  8. [super viewDidLoad];
  9.  
  10. UIView* redSquare = [[UIView alloc] initWithFrame:CGRectZero];
  11. redSquare.backgroundColor = [UIColor redColor];
  12. [self.view addSubview:redSquare];
  13. [redSquare setTranslatesAutoresizingMaskIntoConstraints:NO];
  14. [redSquare.topAnchor constraintEqualToAnchor:self.view.topAnchor].active = YES;
  15. [redSquare.widthAnchor constraintEqualToConstant:100].active = YES;
  16. [redSquare.heightAnchor constraintEqualToConstant:100].active = YES;
  17. }
  18.  
  19. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  20. {
  21. return 1;
  22. }
  23.  
  24. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  25. {
  26. return 5;
  27. }
  28.  
  29. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  30. {
  31. static NSString* reuseIdentifier = @"ri";
  32. UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:reuseIdentifier];
  33. if (!cell)
  34. {
  35. cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier];
  36. }
  37. return cell;
  38. }
  39.  
  40.  
  41. @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement