I'm trying to create a TableViewCell, using a XIB file, but I get this error at execution time:
2013-01-10 17:54:50.297 MainApp[6778:b603] * Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle (loaded)' with name 'DropDownCell''
* Call stack at first throw:
This is what I'm trying to do.
I have a project, with a first Menu. In this project/workspace, I have the class for my first Menu. Inside this project, I have another workspace, with the classes for my second Menu. I mean, this workspace is for the SubViewController's and classes for the options selected in my first Menu. In this workspace, I'm trying to create a DropDownMenu,using the demo from apple, but my app crash. This demo creates the cell's in the table, using a XIB file.
This is the DropDownCell class:
DropDownCell.h
#import <UIKit/UIKit.h>
@interface DropDownCell : UITableViewCell{
  IBOutlet UILabel *textLabel;
  IBOutlet UIImageView *arrow_up;
  IBOutlet UIImageView *arrow_down;
  BOOL isOpen;
}
-(void)setOpen;
-(void)setClosed;
@property (nonatomic)BOOL isOpen;
@property (nonatomic,retain) IBOutlet UILabel *textLabel;
@property (nonatomic,retain) IBOutlet UIImageView *arrow_up;
@property (nonatomic,retain) IBOutlet UIImageView *arrow_down;
@end
DropDownCell.m #import "DropDownCell.h"
@implementation DropDownCell
@synthesize textLabel, arrow_up, arrow_down, isOpen;
-(void)setOpen{
   [arrow_down setHidden:YES];
   [arrow_up setHidden:NO];
   [self setIsOpen:YES];
}
-(void)setClosed{
   [arrow_down setHidden:NO];
   [arrow_up setHidden:YES];
   [self setIsOpen:NO];
}
-(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
   self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
   if(self){
   }
   return self;
}
-(void)setSelected:(BOOL)selected animated:(BOOL)animated{
   [super setSelected:selected animated:animated];
}
-(void)dealloc{
   [super dealloc];
}
@end
And the DropDownCell.xib has one UITableViewCell with a UILabel.
I have another UITableViewController, which uses the DropDownCell XIB. This is the method:
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  static NSString *CellIdentifier = @"MenuCell";
  static NSString *DropDownCellIdentifier = @"DropDownCell";
  if([indexPath row] == 0){
      DropDownCell *cell = (DropDownCell*)[tableView dequeueReusableCellWithIdentifier:DropDownCellIdentifier];
      if(cell == nil){
          NSArray *topLevelObjects = [[NSBundle mainBundle]loadNibNamed:@"DropDownCell" owner:self options:nil];
          for(id currentObject in topLevelObjects){
            if([currentObject isKindOfClass:[DropDownCell class]]){
                cell = (DropDownCell*)currentObject;
                break;
            }
          }
      }
      [[cell textLabel] setText:@"Option 1"];
      return cell;
}
But my app crashes when loads the NIB file... What can be the reason? I'm using Xcode 4.3, and I'm not using storyboards.
 
     
     
     
     
     
    