tags:

views:

12

answers:

1

I got a UIViewController class named DetailViewController, its xib file is called detailViewController.xib.

In the xib file the class is set to DetailViewController class. So it should be all good.

However, when i try to add this view from main view controller, nothing showed up... Here's the code in the main view controller

@interface MainViewController : UIViewController {
    DetailViewController *detailView;
}

@property(nonatomic, retain) IBOutlet DetailViewiPad *detailView;

And i also connected the detailView in the Interface Builder.

Here's the code when i tried to add the detailView:

[self.view addSubview:self.detailView.view];

I put a NSLog in the DetailViewController's viewDidLoad method:

- (void)viewDidLoad {
    [super viewDidLoad];
    NSLog(@"subview iPad did load");
}

I can see the log in the console, which means the DetailViewController did load, but nothing showed up on the iPad screen. It remains the same as the MainViewController. Any idea???

Edit: I tried to init the DetailView in the Main view's viewDidLoad method by calling self.detailView = [[DetailViewController alloc] initWithNibName:@"DetailViewController.xib" bundle:nil];. But it threw an error saying that there's no nib named "DetailViewController".

A: 

It seems to be all good after i restart my mac. So it's all set.

JohnnySun
Actually, I used to drag an NSObject in my MainViewController.xib and change it class to DetailViewController. But now I drag a UIViewController class and change it to DetailViewController class. Then in the attribute tab, set the Nib name to DetailViewController.xib, then it will working fine. I don't know why it used to be all fine in iphone but not in ipad.
JohnnySun