Create UITableView


/ Published in: Objective C
Save to your folder(s)



Copy this code and paste it in your HTML
  1. @interface PurchaseWindowViewController : UIViewController {
  2.  
  3. IBOutlet UITableView* listView;
  4. NSArray* subscriptions;
  5. }
  6.  
  7.  
  8.  
  9. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  10. {
  11. static NSString *MyIdentifier = @"MyIdentifier";
  12.  
  13. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
  14. if (cell == nil) {
  15. cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyIdentifier] autorelease];
  16. }
  17. cell.textLabel.text = [subscriptions objectAtIndex:indexPath.row];
  18. return cell;
  19. }
  20.  
  21. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  22. {
  23. return 4;
  24. }
  25.  
  26.  
  27. // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
  28. - (void)viewDidLoad
  29. {
  30. subscriptions = [[NSArray alloc] initWithObjects:@"8 week - $23.92", @"13 week - $38.87", @"26 week - $77.74", @"52 week - $155.48", nil];
  31. listView.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth;
  32. [listView reloadData];
  33.  
  34. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.