Yadnesh
Yadnesh

Reputation: 1327

UIImageView.hidden = NO; but image is not visible?

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];

}

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

Upvotes: 0

Views: 6743

Answers (3)

chenyi1976
chenyi1976

Reputation: 1122

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;

Upvotes: 0

Bill Burgess
Bill Burgess

Reputation: 14154

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.

Upvotes: 1

Johannes Fahrenkrug
Johannes Fahrenkrug

Reputation: 44730

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.

Upvotes: 1

Related Questions