Advertise here




Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Hiding a UIImageView

tabulltabull Posts: 27Registered Users
edited May 2009 in iOS SDK Development
Hello -

This is my first post to this forum. I have been working with Objective-C for about a month, so I'm quite naive. However, I wrote C and assembly language programs for 8 bit and 16 bit boards I designed myself for over twenty years. But there's a big difference.

I have formed two UIImageViews using IB, and laid both of them over a UIButton. Even though the two views cover the button so one can't see it, the IBAction is still fired when I touch inside and up.

I would like to hide one of the images when the button is pressed. I have searched Apple literature (which contrary to what many say I find very troublesome.) I have tried all sorts of tactics (always guessing) on my own. I've searched the net diligently.

I can't figure out how or even if it is possible to accomplish what I have in mind. I've written a couple of animations, and thought that might be a way to go. but no luck. I thought maybe somehow I could change the alpha, but so far I have failed there too.

Can one of you gurus out there give me some hints? I'll provide any further info necessary.

Thanks,
Dan
Post edited by tabull on

Replies

  • stuffradiostuffradio Posts: 126Registered Users @ @
    edited May 2009
    I'm still quite new as well... I'm not sure 100% how to do it but try something like this
    - (IBAction)yourMethod:(id)sender
    {
       nameOfUIImageView.Hidden = TRUE;
    }
    

    Like I said, I'm new so this is only a guess.
  • orange goldorange gold Posts: 691Registered Users
    edited May 2009
    you were close. i see you come from a flash background :), it is actually this
    - (IBAction)yourMethod:(id)sender
    {
       nameOfUIImageView.hidden = YES;
    }
    
    <font size="7"><font face="Comic Sans MS"><font color="Orange">APPS4LIFE</font></font></font><br />
    search for me in the app store.
  • tabulltabull Posts: 27Registered Users
    edited May 2009
    Actually, the UIImageView was created in Image Builder and is part of a nib. How can I refer specifically to that UIImageView? It doesn't have a name that I know of. There must be some way to make a connection or some such.
  • stuffradiostuffradio Posts: 126Registered Users @ @
    edited May 2009
    tabull wrote: »
    Actually, the UIImageView was created in Image Builder and is part of a nib. How can I refer specifically to that UIImageView? It doesn't have a name that I know of. There must be some way to make a connection or some such.

    In the .h file of your project you need to make a name for it.
    IBOutlet UIImageView *nameOfImageView
    

    and below you need to declare it as a property
    @property (nonatomic, retain) IBOutlet UIImageView *nameOfImageView;
    

    In IB you then control drag from Files owner to the image view and click on nameOfImageView.
  • tabulltabull Posts: 27Registered Users
    edited May 2009
    stuffradio wrote: »
    In the .h file of your project you need to make a name for it.
    IBOutlet UIImageView *nameOfImageView
    

    and below you need to declare it as a property
    @property (nonatomic, retain) IBOutlet UIImageView *nameOfImageView;
    

    In IB you then control drag from Files owner to the image view and click on nameOfImageView.

    I had actually already done all that, except that I left out IBOutlet from the property declaration. I added in the IBOutlet to the property declaration, ran a Build, which was OK except the image was not hidden. I then went to IB, control dragged from Files Owner to the image view, but the only connection I was offered was to the delegate.
  • LockerLocker Posts: 69Registered Users
    edited May 2009
    tabull wrote: »
    I had actually already done all that, except that I left out IBOutlet from the property declaration. I added in the IBOutlet to the property declaration, ran a Build, which was OK except the image was not hidden. I then went to IB, control dragged from Files Owner to the image view, but the only connection I was offered was to the delegate.
    Make sure that you've saved .h file in Xcode, until you do so the outlet wont become available in Interface Builder.
    <a href="http://thrillseekerapp.com"; target="_blank">ts_sig.jpg</a><br />
    <a href="http://thrillseekerapp.com"; target="_blank">Theme Park iPhone & iPod touch app</a>
  • tabulltabull Posts: 27Registered Users
    edited May 2009
    Locker wrote: »
    Make sure that you've saved .h file in Xcode, until you do so the outlet wont become available in Interface Builder.

    Thanks, but that's why I ran a build before trying to make the connection. That forces a save of any modified code files.
  • tabulltabull Posts: 27Registered Users
    edited May 2009
    stuffradio wrote: »
    In the .h file of your project you need to make a name for it.
    IBOutlet UIImageView *nameOfImageView
    

    and below you need to declare it as a property
    @property (nonatomic, retain) IBOutlet UIImageView *nameOfImageView;
    

    In IB you then control drag from Files owner to the image view and click on nameOfImageView.

    Turns out that the connection I needed was not from Files owner but from a ViewController I had added to the main xib. Once I did that, it worked perfectly. Thanks everyone for all the suggestions and help. Slowly but surely I'm starting to get it (I hope.)

    Dan
Sign In or Register to comment.