UIImageView.hidden 属性不起作用?

发布于 2024-12-03 11:24:40 字数 1320 浏览 1 评论 0原文

PanelImage 是全局分配的,并在从 ViewDidLoad 调用的方法中启动

PanelImage = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"panel.png"];
[self.view addsubView:PanelImage];

我的图像正常显示,但是 当我尝试使用隐藏它时

PanelImage.hidden = YES;

它不隐藏 我使用测试该属性

if(PanelImage.hidden) 但我没有通过

我也打印了它,

NSLog(@"panel is hidden %d",PanelImage.hidden);

即使在设置它之后,它也输出“Panel is hide 0”

PanelImage.hidden = 1;

请帮忙,至少告诉我一些调试它的技术。 有很多方法都在使用PanelImage.hidden,它在2天之前就可以工作。现在PanelImage.hidden唯一起作用的是自定义初始化函数(从ViewDidLoad调用) 这也是一个非常大的代码的一部分。

经过大量调试后,我发现 PanelImage.hidden 无法操作

    PanelImage.hidden = YES;//works till here here
    [self GetSymbolAttr];//wont work after this function is called

GetSymbolAttr 的定义

   -(void)GetSymbolAttr
 {

int tmp = 0;
NSArray* PosAndSizeArrForCurrSlot = [[PosAndSizeArr objectAtIndex:SlotId] componentsSeparatedByCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@" "]];
for(NSString* values in PosAndSizeArrForCurrSlot)
    PositionAndSize[tmp++]  = [values intValue];

 }

,因为您可以看到 GetSymbolAttr 中没有发生任何事情,这将使 Pattern.hidden 无法操作

PanelImage is Global allocED and initiated in a method called from ViewDidLoad

PanelImage = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"panel.png"];
[self.view addsubView:PanelImage];

My image comes up properly but
when i try to hide it using

PanelImage.hidden = YES;

it Doesn't hide
i test the property using

if(PanelImage.hidden) but i doesnt pass

i also printed it

NSLog(@"panel is hidden %d",PanelImage.hidden);

it outputs "Panel is hidden 0" even after setting it by

PanelImage.hidden = 1;

please help,atleast tell me some technique to debug it.
there are lots of methods which are using PanelImage.hidden,it used to work before 2days.now only point where PanelImage.hidden works is the custom initialization function(called from ViewDidLoad)
also this is piece of a very big code.

after lots of debugging i came to a point where PanelImage.hidden goes inoperable

    PanelImage.hidden = YES;//works till here here
    [self GetSymbolAttr];//wont work after this function is called

definition of GetSymbolAttr

   -(void)GetSymbolAttr
 {

int tmp = 0;
NSArray* PosAndSizeArrForCurrSlot = [[PosAndSizeArr objectAtIndex:SlotId] componentsSeparatedByCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@" "]];
for(NSString* values in PosAndSizeArrForCurrSlot)
    PositionAndSize[tmp++]  = [values intValue];

 }

as you can see nothing is happening in GetSymbolAttr which will make Pattern.hidden go inoperatble

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

兮颜 2024-12-10 11:24:40

如果 PanelImage.hidden = YES; 现在可以正常工作,那么您可以将其 alpha.set 为零。 PanelImage.alpha = 0 ;

if PanelImage.hidden = YES; is now working than you can do its alpha.set to zero . PanelImage.alpha = 0 ;

停滞 2024-12-10 11:24:40

试试这个:

    UIImageView *PanelImage = [[UIImageView alloc] initWithImage:[UIImage ...]];
    [self.view addsubView:PanelImage];

我没有找到带有 UIImageViewinitWithImageNamed 方法!

try this:

    UIImageView *PanelImage = [[UIImageView alloc] initWithImage:[UIImage ...]];
    [self.view addsubView:PanelImage];

I didn't find initWithImageNamed method with UIImageView !

芸娘子的小脾气 2024-12-10 11:24:40

您是否以相同的方法设置PanelImage.hidden = YES,您正在执行 UIImageView *PanelImage = [[UIImageView alloc]initWithImageNamed:@"Panel.png"]; ?或者您没有使用同名PanelImage 类字段吗?

Do you set PanelImage.hidden = YES in the same metod, where you're doing UIImageView *PanelImage = [[UIImageView alloc]initWithImageNamed:@"Panel.png"];? Or haven't you class field with the same name PanelImage?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文