Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-2523] iOS: ScrollableView problems showing imageviews larger than screen

GitHub Issuen/a
TypeBug
PriorityTrivial
StatusClosed
ResolutionDuplicate
Resolution Date2012-07-26T12:31:49.000+0000
Affected Version/sRelease 1.5.0
Fix Version/sn/a
ComponentsiOS
Labelsn/a
Reportertrident
AssigneeNeeraj Gupta
Created2011-04-15T03:21:53.000+0000
Updated2012-07-26T21:41:49.000+0000

Description

I submit a simple example of a scrollableview with 3 imageviews which are wider than the window's width.

The imageviews of three images 1024x1440 pixels (placed as backgrounds to allow zooming) are sized to the maximum height of the window, and therefore with a wider width; than added to the scrollableview.
The images are double pages of a catalog.

Scrollableview correctly shows just the visible part of the image, but trying to move right showing the other part of the image, it scrolls to the following view.
If you try to first pinch in or out the image (zooming), then scrollableview acts correctly first panning and then scrolling.

The attachments contains app.js, scrollview_problem.js and the three images.
Put them in the resource folder of a new project.
I have Titanium developer 1.2.1, iphone SDK 4.2 and mobile titanium sdk 1.4.2.

Attachments

FileDateSize
scrollview_problem_prj_resources.zip2011-04-15T03:21:54.000+0000673038

Comments

  1. trident 2011-04-15

    I solved patching the objective C source of the ScrollableView class.
    I saw that the inner scrollviews created by the class for each view were not aware of the content size of the view itself. After the first zoom gesture they were and the scrolling was ok. So I modified the source that creates the inner scrollviews to set the contentsize property according to the size of the internal view.

    This is the complete source of the refreshScrollView method from the ScrollableView.m file (mobile SDK 1.5.1).
    The lines added are between comments.

    Hope it's useful to somebody and please take this into consideration in the next mobile sdk release.

       
       -(void)refreshScrollView:(CGRect)visibleBounds readd:(BOOL)readd
       {
       // start code added by Trident
           TiViewProxy *viewproxy;
           TiUIView *mview;
           CGRect vbounds;
       // end code added by Trident
       
           CGRect viewBounds;
           viewBounds.size.width = visibleBounds.size.width;
           viewBounds.size.height = visibleBounds.size.height - (showPageControl ? pageControlHeight : 0);
           viewBounds.origin = CGPointMake(0, 0);
           
           UIScrollView *sv = [self scrollview];
           
           [self refreshPageControl];
           
           if (readd)
           {
               for (UIView *view in [sv subviews])
               {
                   [view removeFromSuperview];
               }
           }
           
           for (int c=0;c<[views count];c++)
           {
               viewBounds.origin.x = c*visibleBounds.size.width;
               
               if (readd)
               {
       // start code added by Trident
                   viewproxy = [views objectAtIndex:c];    
                   mview = [viewproxy view];
                   vbounds = [mview bounds];
       // end code added by Trident
                   //TODO: optimize for non-scaled?
                   InnerScrollView *view = [[InnerScrollView alloc] initWithFrame:viewBounds];
                   [view setMaximumZoomScale:maxScale];
                   [view setMinimumZoomScale:minScale];
                   [view setShowsVerticalScrollIndicator:NO];
                   [view setShowsHorizontalScrollIndicator:NO];
                   [view setDelegate:view];
       //          [view setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight];
                   [view setPagingEnabled:NO];
                   [view setBackgroundColor:[UIColor clearColor]];
                   [view setDelaysContentTouches:NO];
       // start code added by Trident
                   [view setContentSize:vbounds.size];
       // end code added by Trident            
                   [sv addSubview:view];
                   [view release];
               }
               else 
               {
                   UIView *view = [[sv subviews] objectAtIndex:c];
                   view.frame = viewBounds;
               }
           }
           
           if (currentPage==0)
           {
               [self loadNextFrames:true];
           }
           
           if (readd)
           {
               [self renderViewForIndex:currentPage];
           }
           
           CGRect contentBounds;
           contentBounds.origin.x = viewBounds.origin.x;
           contentBounds.origin.y = viewBounds.origin.y;
           contentBounds.size.width = viewBounds.size.width;
           contentBounds.size.height = viewBounds.size.height-(showPageControl ? pageControlHeight : 0);
           contentBounds.size.width *= [views count];
           
           [sv setContentSize:contentBounds.size];
           [sv setFrame:CGRectMake(0, 0, visibleBounds.size.width, visibleBounds.size.height)];
       }
       
  2. Stephen Tramer 2011-04-15

    Need to discuss whether it's appropriate behavior to swipe immediately to the next view, or to pan across current view content.

  3. Stephen Tramer 2012-07-26

    Dupe of TIMOB-2504.

JSON Source