【发布时间】:2012-05-09 03:46:54
【问题描述】:
我在滚动视图中创建了 15 个图像按钮,但只有 1 列, 我想更改行(4 行 * 4 列)
我该怎么做?请提前给我一些,谢谢..
NSUInteger booknumber;
for (booknumber = 1; booknumber <= 15; booknumber++) {
UIButton *button = [self createBtn:booknumber orgx:orgx orgy:orgy];
}
orgx += 100;
orgy += 0;
orgx++;
[mFavorites addSubview:button];
- (UIButton*)createBtn:(int)day orgx:(CGFloat)orgx orgy:(CGFloat)orgy{
UIButton *button=[UIButton buttonWithType:UIButtonTypeCustom];
[button setBackgroundImage:[UIImage imageNamed:@"backplane.png"] forState:UIControlStateNormal];
button.frame = CGRectMake(orgx, orgy, 75, 113);
return button;
}
【问题讨论】:
-
我尝试用for{},但是什么都不加载(我不知道),还要多学习,请多多指教..
-
放上你的代码。像这样的问题让人觉得你没有研究,而是来这里让我们做你的工作。至少通过代码,它表明你已经尝试过了。 (顺便说一句,即使显示代码,您也是少数。通常,我们只是在提问者方面毫不费力地得到这些问题)。
-
原点计算不正确,每次你只是增加x,而你想要一个网格结构?
-
您可以查看此内容以供参考 - stackoverflow.com/questions/5140710/…
标签: ios uiscrollview uibutton