だから私はサブクラス化されたUIView:
.h
@interface HistogramGraphPanel : UIView
@property (strong, nonatomic) UIView *graphView;
-(id)initWithDataset:(Dataset *)dataset;
@end
.m
-(id)initWithDataset:(Dataset *)dataset {
    self = [super init];
    if (self) {
        self.dataset = dataset;
        self.translatesAutoresizingMaskIntoConstraints = FALSE;
        UIView *contentView = [UIView new];
        contentView.translatesAutoresizingMaskIntoConstraints = FALSE;
        contentView.backgroundColor = [UIColor orangeColor];
        contentView.tag = 6;
        self.contentView = contentView;
        UIView *headerView = [UIView new];
        headerView.translatesAutoresizingMaskIntoConstraints = FALSE;
        headerView.backgroundColor = [UIColor blueColor];
        self.headerView = headerView;
        [headerView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[headerView(60)]" options:0 metrics:nil views:NSDictionaryOfVariableBindings(headerView)]];
        [contentView addSubview:headerView];
        [contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[headerView]" options:0 metrics:nil views:NSDictionaryOfVariableBindings(headerView)]];
        [contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[headerView]|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(headerView)]];
        UILabel *headerLabel = [UILabel new];
        headerLabel.translatesAutoresizingMaskIntoConstraints = FALSE;
        headerLabel.font = [UIFont fontWithName:HELVETICA_FONT_STYLE_BOLD size:24];
        headerLabel.text = @"Analysis Histogram";
        headerLabel.backgroundColor = [UIColor clearColor];
        [headerView addSubview:headerLabel];
        [headerView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-[headerLabel]-|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(headerLabel)]];
        [headerView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-[headerLabel]" options:0 metrics:nil views:NSDictionaryOfVariableBindings(headerLabel)]];
        [self createGraphView];
        self = (HistogramGraphPanel *)contentView;
    }
    return self;
}
UIViewサブクラスの作成と使用:
HistogramGraphPanel *graphPanel = [[HistogramGraphPanel alloc] initWithDataset:dataset];
[self.view addSubview:graphPanel];
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:[panel]-[graphPanel]-|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(graphPanel, panel)]];
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-(49)-[graphPanel]-(228)-|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(panel, graphPanel)]];
DLog(@"graphPanel.graphView: %@", graphPanel.graphView);
アクセスしようとするまでうまくいきますgraphPanel.graphView:
2013-04-25 16:44:58.579 [15666:907] -[UIView graphView]: unrecognized selector sent to instance 0x1e0c8320
2013-04-25 16:44:58.580 [15666:907] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView graphView]: unrecognized selector sent to instance 0x1e0c8320'
インスタンス0x1e0c8320は、私が作成したgraphViewのcontentViewです。
プロパティにアクセスしようとしないと、クラッシュすることなく実行されます。
理想はありますか?