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

  • Home
  • SEARCH
  • 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 8623317
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:15:10+00:00 2026-06-12T07:15:10+00:00

I have a project where I am adding selected images to a UIView. Once

  • 0

I have a project where I am adding selected images to a UIView. Once I add an image I can move, rotate, and zoom that image. But let’s say I picked the wrong image and I want to undo. What would be the proper method to handle something like this? Also, let’s say I add multiple but want to clear all of them from the view, what would be the proper method for this?

Here is what I am trying so far:

-(IBAction)undoButtonTapped
{
    self.stampedImageView.image = nil;
}

This will successfully undo the previous action but only that. Let’s say I add two or more images. Maybe I want to undo one or more action but not all of them. This will only undo the most recent action.

Example:

User adds three stamps
To undo 2 stamps:  tap the undo button twice
To delete all stamps:  tap the delete button once

I have figured out how to remove all stamps with one button tap. See below.

Delete Code:

UIView * subview;
while ((subview = [[imageView subviews] lastObject]) != nil)
{
    [subview removeFromSuperview];
}
  • 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-12T07:15:11+00:00Added an answer on June 12, 2026 at 7:15 am

    You can loop through your view’s subviews, testing for whether a particular subview is an image view and then call removeFromSuperview on as many as you want. The views in the subviews will be in the same order as they were added, so to remove the last n items, you need to be enumerate the array of image views from the end. As an example, this method would delete the last 3 image views added:

    -(IBAction)deleteThree:(id)sender {
        NSIndexSet *indxs = [self.view.subviews indexesOfObjectsPassingTest:^BOOL(id obj, NSUInteger idx, BOOL *stop) {
            return [obj isKindOfClass:[UIImageView class]];
        }];
    
        __block int i = 0;
        [indxs enumerateIndexesWithOptions:NSEnumerationReverse usingBlock:^(NSUInteger idx, BOOL *stop) {
            [[self.view.subviews objectAtIndex:idx] removeFromSuperview];
            i++;
            if (i==3) 
                *stop = YES;
        }];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried adding a WebService (asmx based) from a WebForms project to
I have a problem adding ADO.Net Entity Data Model to my existing project, or
I have a django 1.3 project and I'm in the process of adding text
I am using a X.jar and adding to my AspectJ project(in eclipse). I have
I'm looking into adding a jquery modal popup to my mvc project. I have
I have a project with several targets. For most of my classes, I can
I have a web project that I am ripping out all the inline styling
I have a table view project with multiple controllers and another one that is
I have an Mvc3 project that includes both Mvc and Api controllers. When I
I have connected .wsdl file to my project (by adding service reference ). Wcf

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.