UIImageView function

Discussion in 'iOS Development' started by Chicken, Oct 31, 2008.

  1. Chicken

    Chicken Retired Moderator

    Joined:
    Feb 17, 2008
    Messages:
    2,494
    Likes Received:
    7
    Device:
    iPhone 5S
    How can I add a function to my UIImageView I want to make it reboot when the image is touched can someone please help me!
  2. godogshomie

    godogshomie New Member

    Joined:
    Nov 19, 2007
    Messages:
    558
    Likes Received:
    3
    Code:
    - (void) touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event
    {
    UITouch *touch = [touches anyObject];
    myImageView = [touch view];
    if([touch tapCount] == 1) {
    // w/e u do to reboot
    }
    }
    
    
  3. Chicken

    Chicken Retired Moderator

    Joined:
    Feb 17, 2008
    Messages:
    2,494
    Likes Received:
    7
    Device:
    iPhone 5S
    right I have something else but I get an error saying that I need to declare UIControlEventTouchUpInside I dont know how to declare this in my header file can you help?
  4. DotSlashSlash

    DotSlashSlash Active Member

    Joined:
    Feb 29, 2008
    Messages:
    1,134
    Likes Received:
    0
    Device:
    iPhone 3GS (White)
    i know that if you are doing it in xcode you can assign a button to touch up inside but look in the documentation there is an article there
  5. Chicken

    Chicken Retired Moderator

    Joined:
    Feb 17, 2008
    Messages:
    2,494
    Likes Received:
    7
    Device:
    iPhone 5S
    im doing it with the cydia toolchain I am really confused xcode is much simpler
  6. DotSlashSlash

    DotSlashSlash Active Member

    Joined:
    Feb 29, 2008
    Messages:
    1,134
    Likes Received:
    0
    Device:
    iPhone 3GS (White)
    oh sorry lol..
  7. Chicken

    Chicken Retired Moderator

    Joined:
    Feb 17, 2008
    Messages:
    2,494
    Likes Received:
    7
    Device:
    iPhone 5S
    its ok its times like this I wish I had a mac!!

    so can anyone else help me with my decleration problem
  8. SkylarEC

    SkylarEC Super Moderator Emeritus Staff Member

    Joined:
    Sep 19, 2007
    Messages:
    6,642
    Likes Received:
    129
    You don't want a UIImageView. You want a UIButton. Just set its image to the image that you want.

    Code:
    UIButton *yourButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    	yourButton.frame = [[UIScreen mainscreen] bounds];
    	[yourButton addTarget:self action:@selector(yourButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
    	//[yourButton setImage:[UIImage imageNamed:@"YourImage.png"] forState:UIControlStateNormal];
    
    
    //Later in your code
    
    - (void)yourButtonPressed:(id)button {
    	//Do whatever you want to do when the button is pressed here.
    }
    
  9. Chicken

    Chicken Retired Moderator

    Joined:
    Feb 17, 2008
    Messages:
    2,494
    Likes Received:
    7
    Device:
    iPhone 5S
    theres no UIButton in the cydia toolchain
    ------------------double post merged------------------
    I'm going to use UIPushButton now how can I set it as my image at the moment my code is

    UIPushButton* image = [ [ UIPushButton alloc ] initWithImage

    Please Register or Log in to view images

    "/Applications/iBoot.app/icon.png" ];
    [ mainView addSubview: image ];


    but it dosent show anything

Share This Page