Custom view with tip as subtask doesn't seem to load

I created a custom view that loads its contents from nib, for example:

/* PricingDataView.h */

#import <UIKit/UIKIt.h>

@interface PricingDataView : UIView {
  UIView *contentView;
}
@property (nonatomic, retain) IBOutlet UIView *contentView;
@end

/* PricingDataView.m */

#import "PricingDataView.h"

@implementation PricingDataView
@synthesize contentView;

- (id)initWithFrame:(CGRect)frame {
  if ((self = [super initWithFrame:frame])) {
    [[NSBundle mainBundle] loadNibNamed:@"PricingDataView" owner:self options:nil];
    [contentView setFrame:frame];
    [self addSubview:contentView];
  }
  return self;
}

/* ... */

In the nib file, I set it PricingDataViewas File Owner type and connected the output contentViewto IB. I put the usual one UIViewfrom the interface library into the full-sized view shown to the user, and then changed his class name to PricingDataView. All this builds, but nothing is displayed at runtime when it is assumed that my custom view should be.

PricingDataView.initWithFrame, , , -, . , nibs , . ?

+3
3

, UIViewController? documentation initWithFrame: UIView:

Interface Builder , nib. nib , initWithCoder: , nib. , , . .

+10

Interface Builder ,   -(id)initWithCoder:(NSCoder *)aDecoder, initWithFrame.

+1

(PricingDataView) , UIView. initWithFrame:

awakeFromNib . customView View, Nib subView, .

+1

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


All Articles