I have created UIView (say A) object through code and added all the sub views like UIButton, UILabel etc. through code. One other UIView (say B) I have created in XIB. now I am trying to assign A to B. When I Log the sub views of B after assigning, I can see all the sub views of A in B but nothing comes up in the view. I know my logic might be wrong but I didn't get it. Please let me know if its possible or not!
Here is my code:
- (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]);
}
Thanks