Scrollview locked

Discussion in 'iOS Programming' started by AbhishekApple, Jun 30, 2011.

  1. AbhishekApple, Jun 30, 2011
    Last edited: Jun 30, 2011

    AbhishekApple macrumors member

    Joined:
    Aug 5, 2010
    #1
    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];
    
    
     
  2. AbhishekApple thread starter macrumors member

    Joined:
    Aug 5, 2010
    #2
    Its done actually the pos_y was less than the scroll content so increased the scrollview height
     

Share This Page