Reputation: 3980
I have renamed some nib files, from
EEMSystemDetailElpho to EEMSystemDetailElphoView, EEMSystemDetailTransfer to EEMSystemDetailTransferView, EEMSystemDetailProbing to EEMSystemDetailProbingView.
They have corresponding file owners which still are unchanged.
They are all part of a UIScroll-view and the UIScroll view is loaded and shows, however after renaming the nib-files neither of my three subviews are visible. I load the views by allocating and initializing the controllers, as before.
NSMutableArray *controllers = [[NSMutableArray alloc] init];
elphoController = [[EEMSystemDetailElphoController alloc] init];
[controllers addObject:elphoController];
CGRect frame = scrollView.frame;
frame.origin.x = 0;
frame.origin.y = 0;
elphoController.view.frame = frame;
[scrollView addSubview:elphoController.view];
transferController = [[EEMSystemDetailTransferController alloc] init];
[controllers addObject:transferController];
frame.origin.x = frame.size.width;
frame.origin.y = 0;
transferController.view.frame = frame;
[scrollView addSubview:transferController.view];
probingController = [[EEMSystemDetailProbingController alloc] init];
[controllers addObject:probingController];
frame.origin.x = frame.size.width * 2;
frame.origin.y = 0;
probingController.view.frame = frame;
[scrollView addSubview:probingController.view];
viewControllers = controllers;
[controllers release];
I've noticed that if I add my old .nib files to my specific applications folder under Library/Application Support/Iphone Simulator/(current version)/Applications/(specific app), then the views are showing. This indicates that XCode in some way doesn't notice my change of file names. I get no errors when running the application, my views are just not showing.
Any thoughts?
Upvotes: 0
Views: 245
Reputation:
If the nib name differs from the view controller name that manages it then you should use
- (id)initWithNibName:(NSString *)nibName bundle:(NSBundle *)nibBundle
so for instance your first controller would be loaded
elphoController = [EEMSystemDetailElphoController alloc] initWithNibName:@"EEMSystemDetailElphoView" bundle:nil]];
This is the designated initializer for UIViewController
As per Apple's docs
If you specify nil for the nibName parameter, you must either override the loadView method and create your views there or you must provide a nib file in your bundle whose name (without the .nib extension) matches the name of your view controller class. (In this latter case, the class name becomes the name stored in the nibName property.) If you do none of these, the view controller will be unable to load its view.
(emphasis mine)
Only use vanilla init
when the UIViewController
has no nib, or it is guaranteed that the nib name and view controller name are identical. Even in the latter case you really should use the designated initializer and pass nil
for both nibName
and nibBundle
Upvotes: 2
Reputation: 5540
when you are renaming your files then connections will be gone.So please find this.
Upvotes: 0
Reputation: 1208
try to remove the connections and connect back to their respective file owners. remove the build from both simulator and your application folder and run it again.
hope it works.
TNX
Upvotes: 0