Storyboard UIImageview problem

Discussion in 'iOS Programming' started by digitalfortress, Apr 21, 2012.

  1. digitalfortress, Apr 21, 2012
    Last edited by a moderator: Apr 21, 2012

    digitalfortress macrumors newbie

    Nov 9, 2009
    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;
              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!!
  2. digitalfortress thread starter macrumors newbie

    Nov 9, 2009
  3. jnoxx macrumors 65816


    Dec 29, 2010
    Aartselaar // Antwerp // Belgium
    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 :)

Share This Page