gpt4 book ai didi

iphone - 为什么当我单击某个按钮时,我使用的 UILableView 对象或 UIImageView 会隐藏?

转载 作者:行者123 更新时间:2023-12-03 20:15:26 27 4
gpt4 key购买 nike

我正在开发一个项目,其中标签和图像的位置根据我单击的按钮进行对齐。

位置存储在一个数组中,我像下面的代码一样分配了位置

-(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]];

}}

当我第一次单击按钮时,我的标签已对齐。但是,当我继续单击同一按钮时,屏幕上看不到“nameLbl”。我没有在这个项目的任何地方使用隐藏或阿尔法。谁能告诉我解决办法

最佳答案

这应该适合你:

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

您需要将数组中的值存储为 NSNumber。例如:

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

关于iphone - 为什么当我单击某个按钮时,我使用的 UILableView 对象或 UIImageView 会隐藏?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10477211/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com