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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:10:15+00:00 2026-05-24T22:10:15+00:00

My app consists of an image gallery. It is a scroll view which displays

  • 0

My app consists of an image gallery. It is a scroll view which displays pics retrieved from the sqlite db. User can scroll the images, add or delete images etc. I can add a picture to the gallery dynamically. But the problem comes when I need to implement the delete functionality. I use the following code but even after calling removeFromSuperView the image is not getting removed from the scrollview.

-(void)deleteDeck{ 

if(selectedEditDeck!=0){
    [deck deleteSelectedDeck:selectedEditDeck]; //deleting from database
  
   //problem starts here ***
    [(UIImageView*)[decksGallery viewWithTag:selectedEditDeck-1]removeFromSuperview];
    [self loadGallery];
    selectedEditDeck=0;
  //Ends here*****
    
    [tableData release];
    tableData=[NSMutableArray array];
    [self showCardNamesinTable];
    [aTableView reloadData];
}

I have already created the uiscrollview in the loadview method. Then to refresh the view after every deletion and addition of images so that I can display the updated gallery, I use the following piece of code:

-(void)loadGallery{                                                                                //Reloading all for adding a single deck image.

//Database part****
NSString *sqlStr = [NSString stringWithFormat:@"select first_card from decksTable"]; 
char *sql = (char*)[sqlStr UTF8String];
kidsFlashCardAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
NSMutableArray *galleryImagesArray=[appDelegate.dbConnection fetchColumnFromTable:sql col:0];
NSArray *sysPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask,YES);
NSString *docDirectory = [sysPaths objectAtIndex:0];
numberofImages = [galleryImagesArray count];
printf("number is %d",numberofImages);//Database part of code ends here 

//In the following fragment of code I add images to UIscrollView

    for (int i = 0; i < [galleryImagesArray count]; i++) {
    CGFloat yOrigin = i * 65;
    NSString *filePath = [NSString stringWithFormat:@"%@/%@", docDirectory,[galleryImagesArray objectAtIndex:i]];
    galleryImage = [[UIImageView alloc] initWithFrame:CGRectMake(yOrigin+140, 15,50,50 )];
    //galleryImage.tag=[galleryImagesArray count];
    galleryImage.tag=i;
    printf("THE TAG IS %d",galleryImage.tag);
    galleryImage.clipsToBounds=YES;
    galleryImage.layer.cornerRadius=11.0;
    galleryImage.backgroundColor=[UIColor clearColor];
    galleryImage.image =[UIImage imageWithContentsOfFile:filePath];
    [decksGallery addSubview:galleryImage];
    [galleryImage release];
}
decksGallery.contentSize = CGSizeMake(115*[galleryImagesArray count], 80);
//[decksGallery reloadInputViews];
  • 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-24T22:10:16+00:00Added an answer on May 24, 2026 at 10:10 pm

    Make sure your [decksGallery viewWithTag:selectedEditDeck-1] is not returning nil and the image was actually deleted from your db before the refresh code running.

    In addition, you are setting imageView.tag = i; in your creation code, since the i would be 0 which is the tag’s default value for every UIView, you’d better fix your creation code as well.

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

Sidebar

Related Questions

in my app i have a list view. Each list consists of a image,
So, my app consists of a textview in one view controller. When the user
I am working on a iPad ordering web app at the moment which consists
I have an image which I use to frame a tweet. It consists of
My app consists of the screens as shown in the attached image. I added
In my app I have a header bar which consists of a single textview
My web app consists of images stored in the SQL Server db. And, i
Im going to write some android app, which will basically consists of two activities.
My app consists of a function in which I'm trying to lock a table,
I have an app which consists of several different assemblies, one of which holds

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.