大家好我制作一个Xcode应用程序,但现在已经卡住了2天
在我的应用程序中,我必须以用户声明的数量创建一些图像(哪些球)。
,如果用户说make 10 10个球应该出现在我知道的随机位置的同一个屏幕上,以使位置随机但是无法弄清楚如何做...我如何连接到界面构建器? ??
尝试了这个 1.H UIImageView * c [100];
1.M
for (int i = 0; i < "users value" ; i++) {
float x = (float)(67 + ((95 + 22) * i));
UIImageView *c[i] = [[UIImageView alloc]
initWithFrame:CGRectMake(x, 20.0f, 95.0f, 149.0f)];
[ballsView[i]setImage:[UIImage imageNamed:@"1.png"]];
ballsView[i].opaque = YES;
ballsView[i].hidden = NO; /* change to YES for distribution */
}
答案 0 :(得分:-1)
使用它。希望帮助
for (int i = 0; i < "users value" ; i++)
{
float x = (float)(67 + ((95 + 22) * i));
UIImageView *c[i] = [[UIImageView alloc]
initWithFrame:CGRectMake(x, 20.0f, 95.0f, 149.0f)];
c[i].image=[UIImage imageNamed:@"1.png"]];
[ballsView[i] addSubView:c[i]];
ballsView[i].opaque = YES;
ballsView[i].hidden = NO; /* change to YES for distribution */
}