Objective c UIImageView.hidden=否;但图像是不可见的吗?
SomeImage是UIImageView*全局声明的Objective c UIImageView.hidden=否;但图像是不可见的吗?,objective-c,uiimageview,properties,Objective C,Uiimageview,Properties,SomeImage是UIImageView*全局声明的 -(void)InMethodCalledFromViewDidLoad { SomeImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"SomeImage.png"]]; SomeImage.frame = CGRectMake(0, 640, 1024,110); [self.view addSubview:SomeImage]; SomeIm
-(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属性设置为“否”,某些图像仍不可见。您要在什么类型的设备上显示图像
SomeImage.frame = CGRectMake(0, 640, 1024,110);
很可能会尝试在设备可见区域之外显示imageview。
此外,您还应该参考本指南:
只有常量和类应以大写字母开头,变量和方法名称应始终以小写字母开头。这可能是一个“duh”答案,但似乎总是咬我的屁股,您的imageview是否连接到.xib?如果未设置插座,它将不会收到更改。能否在前端和后端放置一些NSLog,以便确保代码执行到使图像可见的程度
-(void)OneMoreMethod{
//SomeImage.hidden = NO;//image becomes visible
NSLog(@"before SecondMethod");
[self SecondMethod];
NSLog(@"after SecondMethod");
SomeImage.hidden = NO;//image becomes visible
NSLog(@"after hidden = No");
}
我猜测的是,[self SecondMethod]中出现了一些崩溃,然后永远不会到达SomeImage.hidden=NO iPad,它是iPad!变量名以大写字母开头是否导致了此行为?否,名称不会导致此行为。移除SomeImage时是否显示图像。hidden=是;第一种方法的线条?@Johannes Fahrenkrug是的,它会显示出来,但无论我调用SomeImage多少次,它都不会再被隐藏。hidden=no;或[某些图像设置隐藏:否];这是否与您的问题有关:?