gridview - Programmatically create a 2*2 and 2*1 grid view in iphone -
currently referring this post , able create 2*2 grid view
int rows = 2; int cols = 2; float gridwidth = 1024.0; float gridheight = 1024.0; float buttonwidth = 100.0; float buttonheight = 100.0; // float gaphorizontal = (gridwidth - (buttonwidth * rows)) / (rows + 1); // float gapvertical = (gridheight - (buttonheight * cols)) / (cols + 1); float gaphorizontal = 40; float gapvertical = 40; float offsetx; float offsety; int count = 0; { offsetx = gaphorizontal + ((count % rows) * (buttonwidth + gaphorizontal)); offsety = gapvertical + ((count / rows) * (buttonheight + gapvertical)); uiview *view = [[uiview alloc] initwithframe:cgrectmake(offsetx, offsety, buttonwidth, buttonheight)]; view.backgroundcolor = [uicolor yellowcolor]; [self.view addsubview:view]; offsetx+= buttonwidth + gaphorizontal; count++; } while(count < rows * cols);
but when try create 2*1 grid view
by changing
int rows = 2; int cols = 1;
i'm not able so. creating 2 views.
is there simple solution available this?
what describe expected behavior. 2 rows 1 column 2 cells, or representation views.
Comments
Post a Comment