関連する TagDisplayCell.m を持つ TagDisplayCell.xib があります。ファイルでは、.m
そのようにビューをロードします。
- (id)initWithCoder:(NSCoder *)aDecoder{
self = [super initWithCoder: aDecoder];
if(self){
//load the interface file from .xib
[[NSBundle mainBundle] loadNibNamed:@"TagDisplayCell" owner:self options:nil];
//add as subview
[self addSubview:self.view];
self.view.translatesAutoresizingMaskIntoConstraints = NO;
[self addConstraint:[self pin:self.view attribute:NSLayoutAttributeTop]];
[self addConstraint:[self pin:self.view attribute:NSLayoutAttributeLeft]];
[self addConstraint:[self pin:self.view attribute:NSLayoutAttributeBottom]];
[self addConstraint:[self pin:self.view attribute:NSLayoutAttributeRight]];
}
return self;
}
私のView Controllerには垂直がありますUiStackView
(コンテンツが行に積み重ねられるように)。TagDisplayCell
この UiStackViewに のインスタンスをいくつか追加したいと考えています。これが私がやっていることです。
//create all the views
for(int i=0; i<[commentsAndTagsArray count]; i++)
{
NSObject *obj =commentsAndTagsArray[i];
if ([obj isKindOfClass:[Tag class]])
{
Tag *tempTag = ((Tag*) obj);
TagDisplayCell *tempTagCell = [[TagDisplayCell alloc] initWithFrame:frame];
[uiStackView addSubview:tempTagCell];
}
}
これを実行すると、画面に何も表示されません。ここで何が欠けていますか?