PDA

View Full Version : Storyboard UIImageview problem




digitalfortress
Apr 21, 2012, 07:47 AM
Hello everybody,

I'm new to iphone/ipad development so please bare with me :)

I have multiple UIImageviews on my storyboard already assigned to images but all of them are hidden, all i want to do is show the UIImageview using its tag based on the button i press (which happens to have the same tag)

here is the code
in the .h file
IBOutlet UIImageView *hintImage;

@property (nonatomic, retain) IBOutlet UIImageView *hintImage;

in the implementation file
@synthesize hintImage;

-(IBAction)appear:(id)sender{
int imageIndex = ((UIButton *)sender).tag;
[hintImage viewWithTag:imageIndex];
hintImage.hidden = NO;
}

here is what happens:
if i just leave it like this and run, nothing happens when i press the button

if i make a reference in the storyboard from any UIImageview to hintImage, only one reference it allowed, i cannot reference the other image views to hintImage, so accordingly in runtime when i click the button only the referenced imageview appears no matter which button i choose

can anybody tell me how to fix it and i if i have a wrong logic!!



digitalfortress
Apr 21, 2012, 10:37 PM
is it a vague question or a hard one :)

jnoxx
Apr 23, 2012, 01:52 AM
you don't need the IBOutlets, you just need to create new pointers, and assign them to the viewWithTag:index blah.
Because the logic is "quite good", but the pointer is wrong (for neat coding).
You need to assign a new UIImageView pointer to viewWithTag:indexthingy.
This will recreate the pointer to that object, and you can set it hidden :)