3

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!!

robbie
  • 51
  • 1
  • 9
  • `YourCustomTableViewCellClass *cell = [tableView dequeueReusableCellWithIdentifier: CellIdentifier forIndexPath:indexPath];` - is this being called in your `- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath` method? – App Dev Guy Feb 24 '15 at 07:16
  • Yeah..u cannto use outlets for your case..u need to use tags(u can set the tag in storyboard itself). – Vamshi Krishna Feb 24 '15 at 07:17
  • You can not connect UITableViewCell as IBOutlet as cell is a repetitive view. – Yuvrajsinh Feb 24 '15 at 07:17
  • @VamshiKrishna,i just saw this question,http://stackoverflow.com/questions/26561461/outlets-cannot-be-connected-to-repeating-content-ios it seem ok to do so. – robbie Feb 24 '15 at 07:23
  • @Yuvrajsinh but i create a new table view cell subclass,and button work,but label could not. – robbie Feb 24 '15 at 07:27
  • If you created new subclass for your cell and given as class of your prototypeCell then all views you add to the prototypeCell can connect as outlet to your custom subclass. – Yuvrajsinh Feb 24 '15 at 07:32
  • You can add a link to a screenshot to your question... – Wain Feb 24 '15 at 07:39
  • I assume so ,but i don't know where i did wrong.There is only two step of it.First,i change the class name of prototype cell.Second,i create a class of it.Then i do the drag@Yuvrajsinh – robbie Feb 24 '15 at 07:40
  • I really want to do that,but i don't have enough reaputaton @Wain – robbie Feb 24 '15 at 07:41
  • A link is just text... – Wain Feb 24 '15 at 07:42

3 Answers3

3
  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!

Saidre
  • 56
  • 4
0

You need to create a subclass for Custom UITableViewCell. Than After you can connect Label outlets.

Check out this great tutorial for creating custom UITableViewCell.

Custom UITableViewCell

Naeem
  • 789
  • 1
  • 10
  • 23
0

To insert referencing outlet by drag you need to do it between @interface and @end statements, like a property (it is actually a property). You can add a button outlet just because buttons have an action outlets, which are methods.

Selesao
  • 1
  • 1