iphone - UITableview not placed correctly in uiscrollview -


i have uiscrollview uses pagecontrol. i'm adding tables scrollview in code. tableviews should have padding of 20px on each side. following.

 cgrect frame = self.scrollview.bounds;         frame.size.width = 280.0f;         frame.size.height = self.scrollview.bounds.size.height;          frame.origin.x = (320 * page)+20;         nslog(@"orgin x %d",(320 * page)+20);         nslog(@"orgin x %f",frame.origin.x);         frame.origin.y = 0;           uitableview *tablestage = [[uitableview alloc]initwithframe:frame];         tablestage.backgroundcolor = [uicolor colorwithred:(250/255.0) green:(248/255.0) blue:(247/255.0) alpha:100];         tablestage.delegate = self;         tablestage.datasource = self;         tablestage.tag = page;          tablestage.contentmode = uiviewcontentmodescaleaspectfit;         [self.scrollview addsubview:tablestage];         [self.pageviews replaceobjectatindex:page withobject:tablestage]; 

but i'm getting following result. enter image description here

like can see next tableview moving more left. idea how can fix this?

try this

cgrect frame = self.scrollview.bounds; float offset=20; frame.size.width = frame.size.width-(2*offset); frame.origin.x = (320 * page)+offset; frame.origin.y = 0; uitableview *tablestage = [[uitableview alloc]initwithframe:frame]; 

and no need line

    tablestage.contentmode = uiviewcontentmodescaleaspectfit; 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -