Note that there are some explanatory texts on larger screens.

plurals
  1. POsmooth scrolling of imageview
    primarykey
    data
    text
    <p>I have added the images to scrollview dynamically. Following is the code:</p> <pre><code>-(void)displayimages { for (int i=0; i&lt;[featuredarray count]; i++) { NSString *image=[[featuredarray objectAtIndex:i]objectForKey:@"img"]; if (i==0) { webview=[[UIImageView alloc]initWithFrame:CGRectMake(i*290+15, 0, 270, 380)]; } else { webview=[[UIImageView alloc]initWithFrame:CGRectMake(i*290+15, 0, 270, 380)]; } webview.backgroundColor=[UIColor clearColor]; webview.layer.borderWidth=4; webview.layer.cornerRadius=4; webview.layer.borderColor=[[UIColor whiteColor]CGColor]; [webview setTag:i]; webview.userInteractionEnabled=YES; NSURL *url = [NSURL URLWithString:image]; [webview setImageWithURL:url placeholderImage:[UIImage imageNamed:@"placeholder.png"]]; [scroll addSubview:webview]; UITapGestureRecognizer *tap1 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handlefirstTap:)]; tap1.delegate=self; tap1.numberOfTapsRequired=1; [webview addGestureRecognizer:tap1]; [tap1 release]; [webview release]; } pages.defersCurrentPageDisplay=YES; scroll.delegate =self; scroll.contentSize = CGSizeMake(290*[featuredarray count],300); scroll.pagingEnabled = YES; pages.numberOfPages = [featuredarray count]-1; pages.currentPage =0; } -(void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView{ int gallerypage = scrollView.contentOffset.x /scrollView.frame.size.width; CGRect frame = scroll.frame; frame.origin.x = frame.size.width-15*gallerypage; NSLog(@"frame.origin.x..%f",frame.origin.x); frame.origin.y =0; [scroll scrollRectToVisible:frame animated:YES]; } -(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { int gallerypage = scrollView.contentOffset.x /scrollView.frame.size.width; CGRect frame = scroll.frame; frame.origin.x=gallerypage*290; frame.origin.y =0; [scroll scrollRectToVisible:frame animated:YES]; } </code></pre> <p>It is showing the images well when I use pagecontroller action </p> <pre><code>-(IBAction)pagecontrolaction:(id)sender { int page = pages.currentPage; CGRect frame = scroll.frame; frame.origin.x=page*290; frame.origin.y =0; [scroll scrollRectToVisible:frame animated:YES]; } </code></pre> <p>but when I used touch event to imageview then it is not displaying the images smoothly. It gets stuck during scrolling.</p> <p><img src="https://i.stack.imgur.com/UrjI3.png" alt=""> </p> <p>These are the preview which shows the current image with the start of second image.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload