Why is the UILableView or UIImageView object that I used hidden when I clicked the button?

I am working on a project in which the positions of the shortcut and images are aligned based on the clicks of the i button.

the positions are stored in an array, and I assigned the position as the following code

-(IBAction)templateButtonClicked:(id)sender {

UIButton *button=(UIButton*)sender;
NSLog(@"button tag is %d",button.tag);

if (button.tag==1) {


    CGPoint companyNameLblpos;
    CGRect companyNameLblSize;
companyNameLblpos.x=[[cnXArr objectAtIndex:j]floatValue];
companyNameLblpos.y=[[cnYArr objectAtIndex:j] floatValue];
    //NSLog(@"cnXArr and cnYArr is %0.2f and %0.2f",companyNameLblpos.x,companyNameLblpos.y);
companyNameLblSize.size.width=[[cnWArr objectAtIndex:j] floatValue];
companyNameLblSize.size.height=[[cnHArr objectAtIndex:j] floatValue];
    companyNameLbl.center=companyNameLblpos;
    companyNameLbl.bounds=companyNameLblSize;



    CGPoint yourNameLblPos;
    CGRect yourNameLblSize;
yourNameLblPos.x=[[ynXArr objectAtIndex:j] floatValue];
yourNameLblPos.y=[[ynYArr objectAtIndex:j] floatValue];
yourNameLblSize.size.width=[[ynWArr objectAtIndex:j] floatValue];
yourNameLblSize.size.height=[[ynHArr objectAtIndex:j] floatValue];
    yourNameLbl.center=yourNameLblPos;
    yourNameLbl.bounds=yourNameLblSize;
    yourNameLbl.textColor=[UIColor blackColor];

    CGPoint designationLblPos;
    CGRect designationLblSize;
designationLblPos.x=[[dXArr objectAtIndex:j] floatValue];
designationLblPos.y=[[dYArr objectAtIndex:j] floatValue];
designationLblSize.size.width=[[dWArr objectAtIndex:j] floatValue];
designationLblSize.size.height=[[dHArr objectAtIndex:j] floatValue];
    designationLbl.center=designationLblPos;
    designationLbl.bounds=designationLblSize;


    CGPoint addrLine1LeftLblPos;
    CGRect addrLine1LeftLblSize;
addrLine1LeftLblPos.x=[[ad1XArr objectAtIndex:j] floatValue];
addrLine1LeftLblPos.y=[[ad1YArr objectAtIndex:j] floatValue];
addrLine1LeftLblSize.size.width=[[ad1WArr objectAtIndex:j] floatValue];
addrLine1LeftLblSize.size.height=[[ad1HArr objectAtIndex:j] floatValue];
    addrLine1LeftLbl.center=addrLine1LeftLblPos;
    addrLine1LeftLbl.bounds=addrLine1LeftLblSize;



    CGPoint addrLine2LeftLblPos;
    CGRect addrLine2LeftLblSize;
addrLine2LeftLblPos.x=[[ad2XArr objectAtIndex:j] floatValue];
addrLine2LeftLblPos.y=[[ad2YArr objectAtIndex:j] floatValue];
addrLine2LeftLblSize.size.width=[[ad2WArr objectAtIndex:j] floatValue];
addrLine2LeftLblSize.size.height=[[ad2HArr objectAtIndex:j] floatValue];
    addrLine2LeftLbl.center=addrLine2LeftLblPos;
    addrLine2LeftLbl.bounds=addrLine2LeftLblSize;
    addrLine2LeftLbl.textColor=[UIColor blackColor];


    CGPoint telNoLblPos;
    CGRect telNoLblSize;
telNoLblPos.x=[[phXArr objectAtIndex:j] floatValue];
telNoLblPos.y=[[phYArr objectAtIndex:j] floatValue];
telNoLblSize.size.width=[[pWArr objectAtIndex:j] floatValue];
telNoLblSize.size.height=[[pHArr objectAtIndex:j] floatValue];
    telNoLbl.center=telNoLblPos;
    telNoLbl.bounds=telNoLblSize;


    CGPoint mobNoLblPos;
    CGRect mobNoLblSize;
mobNoLblPos.x=[[mXArr objectAtIndex:j] floatValue];
mobNoLblPos.y=[[mYArr objectAtIndex:j] floatValue];
mobNoLblSize.size.width=[[mWArr objectAtIndex:j] floatValue];
mobNoLblSize.size.height=[[mHArr objectAtIndex:j] floatValue];
    mobNoLbl.center=mobNoLblPos;
    mobNoLbl.bounds=mobNoLblSize;


    CGPoint emailLblPos;
    CGRect emailLblSize;
emailLblPos.x=[[emXArr objectAtIndex:j] floatValue];
emailLblPos.y=[[emYArr objectAtIndex:j] floatValue];
emailLblSize.size.width=[[emWArr objectAtIndex:j] floatValue];
emailLblSize.size.height=[[emHArr objectAtIndex:j] floatValue];
    emailLbl.center=emailLblPos;
    emailLbl.bounds=emailLblSize;


    CGPoint bCardFrontSubItem1Pos;
    CGRect bCardFrontSubItem1Rect;
bCardFrontSubItem1Pos.x=[[liXArr objectAtIndex:j] floatValue];
bCardFrontSubItem1Pos.y=[[liYArr objectAtIndex:j] floatValue];
bCardFrontSubItem1Rect.size.width=[[liWArr objectAtIndex:j] floatValue];
bCardFrontSubItem1Rect.size.height=[[liHArr objectAtIndex:j] floatValue];
    bCardFrontSubItem1.center=bCardFrontSubItem1Pos;
    bCardFrontSubItem1.bounds=bCardFrontSubItem1Rect;

bCardFront.image=[UIImage imageWithData:[bgImageArr objectAtIndex:j]];
bCardFrontSubItem1.image=[UIImage imageWithData:[logoImageArr objectAtIndex:j]];

}}

When I first press the button, my mark is aligned. But when I keep pressing the same button, "nameLbl" does not appear on the screen. I have not used hidden or alpha anywhere in this project. Can someone please tell me the solution

+3
source share
1 answer

This should work for you:

[nameLbl setFrame:CGRectMake([[dXArr objectAtIndex:0] floatValue], [[dYArr objectAtIndex:0] floatValue], [[dWArr objectAtIndex:0] floatValue], [[dHArr objectAtIndex:0] floatValue]];

You will need to store the values ​​in your arrays as NSNumber. For example:

[dXArr addObject:[NSNumber numberWithFloat:1.0]];
0
source

All Articles