Monday, 9 September 2013

loading UITableViewCell from xib results in loaded the nib but the view outlet was not set

loading UITableViewCell from xib results in loaded the nib but the view
outlet was not set

Let me start by saying I've read all the other questions with the same
title before posting this question again, so please bare with me.
I'm trying to create a UITableViewController that it's UITableViewCell is
a xib file. The Xib file is empty(0 controls) all the controls are created
programatically like this
- (id) initWithTitle: (NSString*)p_title andImage: (UIImage*)p_image
{
//adding checkbox & title
MMCheckbox* myCheckbox = [[MMCheckbox alloc] initWithTitle:p_title
andHeight:20];
myCheckbox.frame = CGRectMake(self.frame.size.width -
myCheckbox.frame.size.width -15,20, myCheckbox.frame.size.width, 20);
myCheckbox.flat = YES;
myCheckbox.strokeColor = [UIColor whiteColor];
myCheckbox.checkColor = [UIColor magentaColor];
myCheckbox.uncheckedColor = [UIColor clearColor];
myCheckbox.tintColor = [UIColor clearColor];
[self addSubview:myCheckbox];
//adding the image
UIImageView* imageView = [[UIImageView alloc] initWithFrame:CGRectMake
(15, 10, 20, 20)];
[imageView setImage: p_image];
return self;
}
In the xib file I placed a UITableViewCell and set it's class to my class
MMCheckboxTableViewCell

in my tableViewController I'm creating the cell loading it from NIB like so
- (UITableViewCell *)tableView:(UITableView *)p_tableView
cellForRowAtIndexPath:(NSIndexPath *)p_indexPath
{
//create a UI tableViewCell
UITableViewCell* cell = [p_tableView
dequeueReusableCellWithIdentifier:@"comboBoxCell"];
if(cell == nil)
{
UIViewController *temporaryController = [[UIViewController alloc]
initWithNibName:@"MMComboBoxTableCell" bundle:nil];
// Grab a pointer to the custom cell.
cell = (MMComboBoxTableCell *)temporaryController.view;
}
}
As mentioned in the beginning I've looked at many post with the same
question and checked to see I've got every thing right according to this
please let me know what I'm missing

No comments:

Post a Comment