我正在尝试在我的 viewController 类中显示 UIView。我从 viewController 中的方法调用 initCard 方法viewDidLoad
。第一个功能有效,但第二个无效。在该函数的第二个版本中,我试图显示的视图没有显示,但程序的其余部分正常运行。我究竟做错了什么?
方法调用viewDidLoad
,工作:
[self initCard];
- (void) initCard {
[[NSBundle mainBundle] loadNibNamed:@"Card1View_iPhone" owner:self options:nil];
[self.view addSubview:self.card1ContainerView];
self.card1ImageView.image = [UIImage imageNamed:@"b1fv.png"];
CGRect sFrame = CGRectMake(100, 100,
self.card1ContainerView.frame.size.width,
self.card1ContainerView.frame.size.height);
self.card1ContainerView.frame = sFrame;
}
方法调用viewDidLoad
,不起作用:
[self initCard:self.card1ContainerView cardImageView:self.card1ImageView];
- (void) initCard: (UIView*)cardContainerView cardImageView:(UIImageView*)cardImageView {
[[NSBundle mainBundle] loadNibNamed:@"Card1View_iPhone" owner:self options:nil];
[self.view addSubview:cardContainerView];
cardImageView.image = [UIImage imageNamed:@"b1fv.png"];
CGRect sFrame = CGRectMake(100, 100,
cardContainerView.frame.size.width,
cardContainerView.frame.size.height);
cardContainerView.frame = sFrame;
}