I have a universal application that works fine on the simulator but when I put it on an actual device (4S and 3rd generation iPad) the View controller interface ("EditNameViewControlleriPhone", ignore the fact iPhone is part of the name) appears only as the iPhone version even though I also have an iPad xib.
Here is a screen shot of how I named stuff:
A button in my SettingViewController brings up the EditName interface. Here is he code for that:
-(IBAction)editclass{
EditNameViewControlleriPhone*vc2 = [[EditNameViewControlleriPhone alloc] init];
vc2.delegate = self;
[self presentModalViewController:vc2 animated:YES];
}
-(void)dismiss{
[self dismissModalViewControllerAnimated:YES];
}
Is this code wrong or is there some naming convention that I'm missing or is it something else? Sorry if this is really simple -- I'm new to Xcode. Thanks
You may manually load the correct interface using the following code:
-(IBAction)editclass{
EditNameViewControlleriPhone *vc2;
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
vc2 = [[EditNameViewControlleriPhone alloc] initWithNibName:@"EditNameViewControlleriPhone_iPhone" bundle:nil];
} else {
vc2 = [[EditNameViewControlleriPhone alloc] initWithNibName:@"EditNameViewControlleriPhone_iPad" bundle:nil];
}
vc2.delegate = self;
[self presentModalViewController:vc2 animated:YES];
}
The if-clause checks whether your current device is an iPad or an iPhone. The initialiser within that clause instantiates the viewController using the right xib-file.
Alternatively, you may leave that up to the system to do by following a simple naming scheme;
EditNameViewControlleriPhone~iphone.xib
for your iPhone Version
EditNameViewControlleriPhone~ipad.xib
for your iPad Version
That way, your code may remain as is.
Whenever you find differences in files not being available on device or simulator and vice versa, the usual reason is a problem in capitals. The simulator usually is case-insensitive (depends on your OSX filesystem), the device is case-sensitive (always).
Last but not least, a build-clean often does wonders when things still keep bugging without plausible explanation.