Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

digitalfortress

macrumors newbie
Original poster
Nov 9, 2009
7
0
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
Code:
 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!!
 
Last edited by a moderator:
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 :)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.