How to create dynamic cell for table view using nib files

I am learning how to work with pens and the beginner in general.

I have a table view and another view where I create objects to populate that table view. I am also using master data.

My table view is not populating ... This is my cellForRowAtIndexPath:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *cellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath];

    Target *target = [self.fetchedResultController objectAtIndexPath:indexPath];

    cell.textLabel.font = [UIFont fontWithName:@"Candara-Bold" size:20];

    cell.textLabel.text = target.body;

    // Configure the cell...

    return cell;
}

      

And this is my nib:

enter image description here

Would love to get help here ... thanks!

+3


source to share


1 answer


you can use autorun I think this is the easiest way!

when you are using nib you must register your nib

example: tableView.registerNib (UINib (nibName: StoreCell, bundle: nil), forCellReuseIdentifier: StoreCell)



and you should have UILabel number of lines set to 0

this test project for you https://www.dropbox.com/s/i5cwzok1327vv1e/tableTest.zip?dl=0 enter link here

+1


source







All Articles