我们可以将UIView对象分配给XIB的UIView对象吗?

我们可以将UIView对象分配给XIB的UIView对象吗?,uiview,xib,nib,iboutlet,Uiview,Xib,Nib,Iboutlet,我已经通过代码创建了UIView,比如说一个对象,并通过代码添加了所有子视图,如UIButton、UILabel等。另一个UIB视图是我在XIB中创建的。现在我正在尝试将A分配给B。当我在分配后记录B的子视图时,我可以在B中看到A的所有子视图,但视图中没有显示任何内容。我知道我的逻辑可能是错的,但我不明白。如果可能的话,请告诉我 这是我的密码: - (UIView*)createButtonView:(NSInteger)viewTag avatarImageName:(NSString*)av

我已经通过代码创建了UIView,比如说一个对象,并通过代码添加了所有子视图,如UIButton、UILabel等。另一个UIB视图是我在XIB中创建的。现在我正在尝试将A分配给B。当我在分配后记录B的子视图时,我可以在B中看到A的所有子视图,但视图中没有显示任何内容。我知道我的逻辑可能是错的,但我不明白。如果可能的话,请告诉我

这是我的密码:

- (UIView*)createButtonView:(NSInteger)viewTag avatarImageName:(NSString*)avatarImageName cardImageName:(NSString*)cardImageName ballImageName:(NSString*)ballImageName
{
    buttonBGView = [[UIView alloc] initWithFrame:CGRectMake(15,86,290,290)];
    buttonBGView.tag = viewTag;

    UIImageView *avatarImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 206, 84, 84)];
    avatarImageView.image = [UIImage imageNamed:avatarImageName];
    [buttonBGView addSubview:avatarImageView];

    UIButton *temoCardButton  = [[UIButton alloc] initWithFrame:CGRectMake(58, 42, 188, 222)];
    temoCardButton.tag = viewTag;
    [temoCardButton setImage:[UIImage imageNamed:cardImageName] forState:UIControlStateNormal];
    [temoCardButton addTarget:self action:@selector(cardButtonTapped:) forControlEvents:UIControlEventTouchUpInside];
    [buttonBGView addSubview:temoCardButton];

    UILabel *scoreLabel = [[UILabel alloc] initWithFrame:CGRectMake(228, 0, 30, 30)];
    scoreLabel.text = [cardPointsArray objectAtIndex:randomIndex];
    scoreLabel.textAlignment = UITextAlignmentCenter;
    [buttonBGView addSubview:scoreLabel];

    buttonBGView.backgroundColor = [UIColor redColor];

    return buttonBGView;
}


-(void)cardButtonTapped:(id)sender
{
    NSLog(@"%@",[buttonBGView subviews]);

    self.cardTappedView = buttonBGView;

    NSLog(@"%@",[self.cardTappedView subviews]);
}
谢谢