Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

AbhishekApple

macrumors member
Original poster
Aug 5, 2010
86
0
I want to scroll vertically..
When i comment the code in orange it works fine horizontal scroll with subviews in single row.
But with the orange code i have the multiple row subviews in the Scrollview
but with this scroll gets locked.

Code:
#define TILE_WIDTH 100.0
#define TILE_HEIGHT 60.0
#define TILE_H_PADDING 5.0
#define TILE_V_PADDING 5.0



UIScrollView *svASource = [[UIScrollView alloc]initWithFrame:CGRectMake(rect.origin.x, rect.origin.y+20 , 320.0, 210.0)];
    [svASource setCanCancelContentTouches:NO];
	[svASource setClipsToBounds:NO];
    [svASource setBackgroundColor:[UIColor blackColor]];
    [svASource setAlpha:0.8];
    
    float pos_x = TILE_H_PADDING;
    float pos_y = TILE_V_PADDING;
    for(int i =0 ;i<7 ; i++){
        SourceView *svTile = [[SourceView alloc] initWithFrame:CGRectMake(pos_x, pos_y , TILE_WIDTH , TILE_HEIGHT)];
        svTile.sourceId = @"1";
        svTile.sourceName = @"Bussiness";
        
        [svTile createSubView];
        
        pos_x =  pos_x + TILE_WIDTH + TILE_H_PADDING;
       [COLOR="DarkOrange"] if(pos_x ==  320.0){
            pos_x = TILE_H_PADDING;   
            pos_y = pos_y + TILE_HEIGHT + TILE_V_PADDING;
        }[/COLOR]
        
        [svASource addSubview:svTile];
        
    }
    
    [svASource setContentSize:CGSizeMake(pos_x, TILE_HEIGHT)];
  [COLOR="DarkOrange"] // [svASource setContentSize:CGSizeMake(320.0, pos_y)];[/COLOR]
    [self.view addSubview:svASource];
 
Last edited:

AbhishekApple

macrumors member
Original poster
Aug 5, 2010
86
0
Its done actually the pos_y was less than the scroll content so increased the scrollview height
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.