Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6817439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:03:18+00:00 2026-05-26T21:03:18+00:00

I’m making an ios application and am having trouble using a switch statement to

  • 0

I’m making an ios application and am having trouble using a switch statement to see if a UIButton element was pressed.
This is who I want the end product to work: I have multiple uncolored images (by uncolored I mean white, a UIImage). When an uncolored image is tapped a subview opens with colored boxes (UIButtons, 24 of them, each with individual colors.). When a colored box button is selected and the back button on the toolbar is pressed, the subview closes and the original view re-appears with the uncolored image (the one selected to open the subview) now colored with the desired color selected in the subview.

I want to use a switch statement to find which uncolored image and which color was selected (all UIButton elements). I do not know what to put as an expression in the switch statement because I’m dealing with UIButtons. The rest of the switch statement compares the value of the UIButton element to see if it’s equal to YES (when the button is pressed), and if it is, it returns a string. I also want to know how to connect an IBAction to a UIImage (so when the images are tapped a subview opens).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T21:03:18+00:00Added an answer on May 26, 2026 at 9:03 pm

    I’m a little rusty on iOS development but you could probably do the following:

    Set the buttons to the same event handler and use the sender attribute to get to the tag element of the button which you can specify to each button.

    - (IBAction) doStuff:(id) sender {
    UIButton *button = (UIButton*) sender;
    switch(button.tag)
    {
       //do stuff
    }
    

    If this doesn’t work out for you, you can use any of the button properties you see fit to differentiate between them such as title, title color and so on.

    For best practices i’d advise you to also check if the sender is of type UIButton before trying to cast it into an object.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am making an ios application for some insurance company, what i want to
I am making application with OpenGL in IOS using PVR texture for making 3D
I am making an web application for an iOS app I made. I want
I'm making my first iOS application to be run specifically on an iPad as
let's start off with the problem statement: My iOS application has a login form.
I am making an iOS app where I'm using the GDataXML library for xml
I'm making a graph for my iOS app, using the Core Plot library However
I am programmatically building a UINavigationContoller for iOS and am having problems making it
I'm making a game using cocos2d for iOS. When the main gameplay layer constructor
Writing a mapping application on iOS, making use of OpenStreetMap tiles. Map tile images

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.