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.
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
Post a Comment