I am not exactly sure the best practice of doing this, so I thought I'd ask.
Here's the program's objective:
- A custom navigation controller created via a root UIViewController that does not actually subclass UINavigationController(To easily manipulate the design)
- Nested view controllers for different screens (manipulated by the main view controller)
- Each nested view controller has its own nib file
Currently, I have it working, however each nested view controller is not a view controller but a subclassed UIView. I feel like this is bad practice because I am using these UIViews in a view controller way but without the functions of a view controller (ie. viewDidLoad). Also, these UIViews are taking on the usual delegate methods of a UIViewController (which really sets off red flags).
Is this actually bad practice?
Things I am afraid of when trying to switch to UIViewControllers are that I would still have to make a subclass of UIView to identify which view to point to when I load the nib via:
NSArray *bundle = [[NSBundle mainBundle] loadNibNamed:nibName owner:self options:nil];
for (id object in bundle) {
if ([object isKindOfClass:[SubclassedUIView class]])
currentScreenViewController = (SubclassedUIView *)object;
}
I haven't checked yet, but I assume I have to do "SubclassedUIView" rather than just UIView in that statement because there are other UIView objects in the bundle. But then again, that situation may be better off than the current one.
A different solution may be to make MainViewController a delegate for all of the UIViews that require a delegate and create categories of the MainViewController containing the delegate methods for each nested nib.
Any idea here?