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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:33:39+00:00 2026-06-10T04:33:39+00:00

I am Using UIImageView in UIScrollView to display Image gallery. Here is my Code

  • 0

I am Using UIImageView in UIScrollView to display Image gallery.
Here is my Code :

    [scrollView1 setBackgroundColor:[UIColor blackColor]];
    [scrollView1 setCanCancelContentTouches:NO];
    scrollView1.indicatorStyle = UIScrollViewIndicatorStyleWhite;
    scrollView1.clipsToBounds = YES;
    scrollView1.scrollEnabled = YES;
    scrollView1.pagingEnabled = YES;


NSUInteger i;
for (i = 0; i <= kNumImages; i++)
{
    imageView.userInteractionEnabled = YES;

    imageName = [NSString stringWithFormat:@"image%d.jpg", i];
    UIImage *image = [UIImage imageNamed:imageName];
    imageView = [[UIImageView alloc] initWithImage:image];
    imageView.contentMode = UIViewContentModeScaleAspectFit;

    CGRect rect = imageView.frame;
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
    {
        rect.size.height = kScrollObjHeight;
        rect.size.width = kScrollObjWidth;

    }
    else if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
    {
        rect.size.height = kScrollObjHeight_ipad;
        rect.size.width = kScrollObjWidth_ipad;
    }

    imageView.frame = rect;
    imageView.tag = i;
    [scrollView1 addSubview:imageView];
}  

Now i have a save button to save image in library. for that i have to find every image tag on scrolling. I thought it can be possible by detecting a swipe gesture on UIImageView and can get imageView.tag.
I searched many thing but didn’t get much luck. I understand only is it is difficult to recognize swipe in scroll.

I am new to this Gesture things. Can anyone suggest me what to do?
IS there any other way to get particular imagetag ? Or if i have to go with only this Gesturing thins then how ?

Any help would be a great help..!
Thank you.

  • 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-10T04:33:40+00:00Added an answer on June 10, 2026 at 4:33 am

    In my opinion, you have a couple of options:

    1.
    Add a UISwipeGestureRecognizer to you UIImageView, and in it’s action method change the imageView’s image. For example

    UISwipeGestureRecognizer *mySwipeGestureRecognizer = [[UISwipeGestureRecognizer alloc] init];
    [mySwipeGestureRecognizer addTarget:self action:@selector(gestureAction:)];
    [imageView addGestureRecognizer:mySwipeGestureRecognizer];
    
    -(void)gestureAction:(id)sender  //Here you can also make some validations so to make sure the gesture is finished
    {
    imageView.image = [UIImage imageNamed:@"someOtherImage"];
    }
    

    And then just save the imageView’s image.

    2.
    The other option would be to set the imageView’s frame according to the number of images and then simpy get the imageView’s X coordinate to calculate what image it is displaying.For example,

    for(int i=0; i < numeberOfImages; i++)
    {
    imageView.frame = CGSizeMake(320*i,0,100,100);
    [self.view addSubview:imageView];
    }
    

    Then get the scoll’s position to figure out which image is displaying.

    Also, I think another way to do this would be to implement the scrollView’s delegate and in the method

    - (void)scrollViewDidScroll:(UIScrollView *)scrollView
    

    have a variable to count how many times the user has scrolled and then calculate what image is displaying. Don’t forget to set

    scrollView.delegate = self;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i want to display image in UIImageView which is on the UIScrollView and using
I am using the following code to try and display an image in a
I am using an UIImageView to load an image with aspectfit. Hence the image
Iam developing one application.In that iam using one uiimageview.And take another image view and
I'm using a UIImageView as a background-image and placed multiple UIButtons on it. Now
I am trying to animate an image using following code: [UIView beginAnimations:nil context:NULL]; [UIView
I have an UIImageView with an image (map) inside of a UIScrollView. I add
I created a custom AQGridViewCell. By using UIImageView everything works. The image appears and
I am using single UIImageView object, allocated memory it once. But changing the image
I'm using UIScrollView in which I have placed a UIImageView and a UITextView .

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.