CodeMoto
CodeMoto

Reputation: 353

Storyboard & 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle

I'm not even sure if I'm doing this right but this is what I'm attempting to do. I have a storyboard that includes a table view - which is populated programmatically - all of which works. I also have another ViewController within the storyboard that is essentially going to show the details of whatever is selected in the table view. There is no seque between the table view and detail view in the storyboard - should there be? - and I have created a class to handle this detail view.

So I have this in my detailViewController.h

#import <UIKit/UIKit.h>

@class Profile;

@interface MedStaffDetailViewController : UIViewController

@property (weak, nonatomic) IBOutlet UIImageView *profileImage;

@property (weak, nonatomic) IBOutlet UIBarButtonItem *profileMobile;

@property (weak, nonatomic) IBOutlet UIBarButtonItem *profilePhone;

@property (weak, nonatomic) IBOutlet UIBarButtonItem *profileEmail;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil detail:(Profile *)profile title:(NSString *)title;


@end

And this in its implementation:

#import "MedStaffDetailViewController.h"
#import "MedStaffViewController.h"
#import "Profile.h"

@interface MedStaffDetailViewController ()

@end

@implementation MedStaffDetailViewController
@synthesize profileEmail, profileImage, profileMobile, profilePhone;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil detail:(Profile *)profile title:(NSString *)title
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
        self.title = title;

    }
    return self;
}
@end

I simply want to handle the selection of a row in the table view to show this detail view with the appropriate data - I had this working when I was simply doing a master/view type app - but now I'm using a storyboard so I can learn.

I've set the class to MedStaffDetailViewController in the identity inspector for the detail view and have the following in the table view controller:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    // Navigation logic may go here. Create and push another view controller.
    /*
     <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil];
     // ...
     // Pass the selected object to the new view controller.
     [self.navigationController pushViewController:detailViewController animated:YES];
     */

    _showProfile = [_profileArray objectAtIndex:indexPath.row];
    NSLog(@"Selected: %@", [_showProfile lastName]);

    self.detailViewController = [[MedStaffDetailViewController alloc] initWithNibName:@"MedStaffDetailViewController" bundle:nil detail:_showProfile title:@"This is the title"];

    [self.navigationController pushViewController:self.detailViewController animated:YES];


}

All of this builds fine but throws the error in the title of this question when ran. Should - or do I - need to create a seque in the storyboard? How would I go about getting this detail view to show when a row is selected.

Upvotes: 0

Views: 3624

Answers (1)

juan
juan

Reputation: 973

you can use:

UIStoryboard*  sb = [UIStoryboard storyboardWithName:@"mystoryboard" bundle:nil];
UIViewController* vc = [sb instantiateViewControllerWithIdentifier:@"MedStaffDetailViewController"];

Upvotes: 2

Related Questions