UIImageView.hidden 属性不起作用?
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果
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 ;
试试这个:
我没有找到带有
UIImageView
的initWithImageNamed
方法!try this:
I didn't find
initWithImageNamed
method withUIImageView
!您是否以相同的方法设置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?