本文介绍了UIImageView.hidden = NO;但图像不可见?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SomeImage 是 UIImageView* 全局声明的

SomeImage is UIImageView* globally declared

-(void)InMethodCalledFromViewDidLoad
{
    SomeImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"SomeImage.png"]];
SomeImage.frame = CGRectMake(0, 640, 1024,110);
[self.view addSubview:SomeImage];
    SomeImage.hidden = YES;
    [self OneMoreMethod];
}


-(void)OneMoreMethod{
SomeImage.hidden = NO;//image becomes visible

[self SecondMethod];
/*but now from this point onwards even if SomeImage.hidden changed to NO then only nummerical value of SomeImage.hidden changes but image itself stays hidden doesnt become visible at all */
 }


 -(void)SecondMethod

 {

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

}

我无法理解为什么即使在调用 SecondMethod 后将 hiiden 属性设置为 NO 之后 SomeImage 也不可见.

i am not able to understand why SomeImage is not being visible even after setting hiiden property to NO after SecondMethod is called.

推荐答案

这可能是一个废话"的答案,但似乎总是咬我的屁股,你的 imageview 连接到你的 .xib 了吗?如果未设置插座,则不会收到更改.

This might be a "duh" answer, but seems to always bite me in the butt, is your imageview connected to your .xib? If the outlet isn't set, it won't receive the changes.

这篇关于UIImageView.hidden = NO;但图像不可见?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 12:21