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 t开发者_Python百科hen 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];
}
i am not able to understand why SomeImage is not being visible even after setting hiiden property to NO after SecondMethod is called.
What kind of device are you trying to display the image on?
SomeImage.frame = CGRectMake(0, 640, 1024,110);
Will most likely try to display the imageview outside of the visible area of your device. Also you should really consult this guide: http://google-styleguide.googlecode.com/svn/trunk/objcguide.xml
Only constants and classes should start with a capital letter, variable and method names should always start with a lowercase letter.
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.
Can you put some NSLog on the front and end, so that you can make sure the code will execute to the point you make the image visible?
-(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");
}
What I am guess is that there is some crash in the [self SecondMethod] , then never arrive SomeImage.hidden = NO;
精彩评论