Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - (void)viewDidLoad
- {
- [super viewDidLoad];
- arr = [NSArray arrayWithObjects:@"aaa", @"bbb", @"ccc", @"ddd", @"eee", @"fff", nil];
- myTableView = [[UITableView alloc]initWithFrame:CGRectMake(20, 130, 280, 220)];
- [myTableView registerClass:[CustomCell class] forCellReuseIdentifier:@"Cell"];
- myTableView.delegate = self;
- myTableView.dataSource = self;
- [self.view addSubview:myTableView];
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- static NSString* cellIdentifier = @"Cell";
- CustomCell* cell = (CustomCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier];
- if (cell == nil) {
- cell = [[CustomCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
- }
- cell.customLabel.text = [arr objectAtIndex:indexPath.row];
- return cell;
- }
- - (id)init{
- self = [super init];
- if (self){
- self.backgroundColor = [UIColor redColor];
- //But in ViewController, cell is not red.
- }
- return self;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement