If you ever need to create and dequeue a custom cell programatically (not use storyboards) do this
Code
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *cellIdentifier = @"Cell"; [tableView registerClass:[TrackCell class] forCellReuseIdentifier:cellIdentifier]; TrackCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath]; Track *track = [self.tracks objectAtIndex:indexPath.row]; cell.titleLabel.text = track.title; cell.artistLabel.text = track.artist; UIImage *albumImage = [UIImage imageNamed:track.albumImage]; cell.imageView.image = albumImage; return cell; }
How to create a UITableViewCell and dequeue programatically – Project Management World
Sep 28, 2017 @ 22:54:30