0

so I'm writing Obj-C for iOS, and something "strange" is happening..

I have an MVC, with a UITableView (private):

@interface MVC ()

@property (strong, nonatomic) IBOutlet UITableView *tableView;
@property (strong, nonatomic) CellVC *cell1;
@property (strong, nonatomic) CellVC *cell2;

@end

I load the table view up with a few custom cells. My custom cell class is actually a UIViewController... so I instantiate a few, and set cell.contentView to the corresponding CellVC.view inside the tableView:cellForRowAtIndexPath: method. My custom cell class:

@interface CellVC : UIViewController

@property (strong, nonatomic) IBOutlet UIKnob *knob1;
@property (strong, nonatomic) IBOutlet UIKnob *knob2;
@property (strong, nonatomic) IBOutlet UIKnob *knob3;
@property (strong, nonatomic) IBOutlet UIKnob *knob4;

@end

In case you're wondering, I've written a subclass of UIControl named UIKnob...

In CellVC's viewDidAppear: method, I've set a breakpoint to check the values of every knob. Each knob is non-nil, so I am happy... they have all been created.

My goal is to set MVC as the delegate of each knob. (4 knobs for each cell) If I set a breakpoint anywhere in MVC, the value of each knob is nil??...

cell1.knob1.delegate = self;

will not work because the knobs only exist inside CellVC.m ...

Any ideas??

DanMoore
  • 621
  • 1
  • 8
  • 14
  • 2
    Your custom cell is a UIViewController? That is not going to work. UITableView manages UITableViewCell objects and nothing else. For starters put your custom views inside a UITableViewCell. – Nicholas Hart Aug 19 '13 at 18:16
  • Okay, I will definitely start there... A friend wrote the CellVC class and it seemed to be working just fine in the app until now when I need to set the delegate. Thanks man – DanMoore Aug 19 '13 at 18:20
  • check this out..... http://stackoverflow.com/questions/540345/how-do-you-load-custom-uitableviewcells-from-xib-files – DanMoore Aug 19 '13 at 18:54
  • The first answer shows a UIViewController being loaded from a .XIB and thrown into a TableViewCell.. which is just a view – DanMoore Aug 19 '13 at 18:55

0 Answers0