Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why Label Outlets cannot be connected to UITableViewCell Class

I create a table view cell subclass and set it as the class of the prototype.I want to add the outlets to that class and connect them.

But xcode do not respond.

And i try to add the outlets of button in the next time,it works.

I want to display a picture,it is pity that i don't have enough reputations.

I don't understand why this happen.Can somebody help me,Plesae!!

like image 965
robbie Avatar asked May 14 '26 21:05

robbie


1 Answers

  1. Create a xib file. Delete UIView and drag UITableviewcell.
  2. Set your UITableviewcell class and a identifier for the cell
  3. Drag the components on the cell and connect them with your class.
  4. On the method (void)viewDidLoad of your UITableViewController, set:

    [self.tableView registerNib:[UINib nibWithNibName:nameOfXibFile bundle:[NSBundle mainBundle]] forCellWithReuseIdentifier:identifierOfCell];

  5. On the method (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath, set:

    YourClassTableViewCell *cell = [tableView dequeueReusableCellWithReuseIdentifier:identifierOfCell forIndexPath:indexPath];

    and set the values for the labels cell.label.text = @"Your text".

Good luck!

like image 143
Saidre Avatar answered May 17 '26 12:05

Saidre