2012-07-29 62 views
0

大家好我做Xcode的應用程序,但現在已經被困2天如何創建的UIImageView動態(XCODE)

在我的應用程序

我要創建由所列的數額,一些圖像(這球)用戶。

e,g如果用戶說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 */   
    } 
+1

了它爲(INT I = 0;我 Ifti 2012-07-29 08:01:25

+0

只需將此評論作爲答案並接受它,這將提高您的聲譽和您的接受率。 – 2012-08-06 10:08:34

回答

-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 */   
}