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 8841291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:40:43+00:00 2026-06-14T10:40:43+00:00

I have a UIView that has UILabels, UISliders, UITextboxes, etc. in it. I want

  • 0

I have a UIView that has UILabels, UISliders, UITextboxes, etc. in it. I want to perform an action on just the sliders. How is this done? Currently, I have

int count = 0;
for (UIView *subview in [myView subviews])
{
  if ([subview isKindOfClass:[UISlider class]]);
  {
    [subview removeFromSuperview];
    NSLog(@"Class for object removed is %@",[subview class]);
    count ++;
  }
  //else{do nothing - subview isn't a slider, so I don't care about it}
}
NSLog(@"count = %d",count);

When I run this code, everything is affected (sliders, as well as the labels, textboxes, and everything else). From what I gather from reading other posts, using isKindOfClass with arrays is kinda glitchy, but I thought that was only when trying to do isKindOfClass:[NSArray class]. Or am I wrong on that? If this nesting of isKindOfClass inside a for loop isn’t allowed, how do I perform actions on just certain items on my view?

EDIT: added whole code for one implementation of this. The count is off, and NSLog is telling me a whole bunch of UILabels are being removed. My view is completely emptied of everything after this runs.

EDIT 2: added ; at end of if statement like I have in my actual code. I removed it in my code and I now am getting the behavior I expected.

  • 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-06-14T10:40:45+00:00Added an answer on June 14, 2026 at 10:40 am

    Turned out I had a typo. The ; at the end of my if statement was essentially making it like I didn’t have an if in there at all, which is why everything was being removed from my view. Removing the ; made the code in my Question work as intended.

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

Sidebar

Related Questions

I want to have a UIView subclass that has a border image, but I
I have a UIView subclass ( CustomView for purposes of this question) that has
Suppose I have a UIView that has some buttons and stuff, and I want
I have created a custom UIView that has some set of UILabels in it.
I have a UIView that has several UIImageViews as subviews. Each of these subviews
I have a UIView container that has two UIImageView s inside it, one partially
I have a subview that has been added to my UIView. The idea is
I have a little app up that has both CCLayer view and UIView. That
I have a UIView that contains a UIScrollView and I want to be able
I have a UIView inside of a UIScrollView that I want to resize. I

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.