How to use a generic (NSObject) controller with subviews of a UIViewController?

I have a UIViewController that loads multiple subzones at different times based on user interaction. I originally built all of these routines in code without nib files. Now I move on to nib files with custom subclasses of UIView.

Some of these subzones display static data, and I use loadNibNamed: owner: options: to load them into the view controller. Others contain the controls I need to access.

I (sort of) understand the reasons why Apple says to use a single view controller on the content screen, using common controller objects (NSObjects) to manage the subsections of the screen.

I need a view controller, general controller, presentation class, and tip. How to put it all together?

My working assumptions and subsequent questions:

  • I will associate the view class with the thread in the word "class identifier" down in IB.
  • The view controller will coordinate the overall interaction of the screen. when necessary, it will instantiate the primary controller.
  • Does the general controller load the NIB? How?
  • Do I define points and actions in this class of view, or should they be in a common controller?
  • How to transfer messages between a view controller and a common controller?

If someone can give me sample code using the controller this way, it will help me understand. None of the books or stackoverflow books I read that I have read have done this yet.

+3
2

, , :

  • NSObject, CustomController
  • CustomController.h, UIView nib
  • nib CustomController
  • , , UIView
  • CustomController.m init nib

- (id)init {
    self = [super init];
    if (self != nil)
        [self loadNib];

    return self;
}

- (BOOL)loadNib {
    NSArray *topLevelObjs = nil;
    topLevelObjs = [[NSBundle mainBundle] loadNibNamed:@"CustomView" owner:self options:nil];

    if (topLevelObjs == nil) {
        NSLog(@"Error! Could not load nib file.\n");
        return NO;
    }
    return YES;
}

NSObject .

+3

, , , " UIView" - , - , , - , xib ( xib, IB).

, . iOS - , .

. , , :

UIView initWithFrame NIB. NIB?

- / uiview (.. "loginRequested: userName: passWord" , ).

(, ) xib , - xib . whicever, .

+1

Source: https://habr.com/ru/post/1735873/