2011-05-08 79 views
0

是什麼這行代碼:的UIImageView * XXX = [[UIImageView的頁頭] initWithImage:XXX]

UIImageView* flakeView = [[UIImageView alloc] initWithImage:flakeImage]; 

,如果它再幫我有這樣的:

int startX2 = round(random() % 480); 
// set the flake start position 
flakeView.frame = CGRectMake(startX2, 330.0, 30, 20); 
flakeView.alpha = 1; 

// put the flake in our main view 
[self.view addSubview:flakeView]; 

回答

1

行:

UIImageView* flakeView = [[UIImageView alloc] initWithImage:flakeImage];

創建容器"UIImageView"包含圖像0的對象存儲在ivar中flakeImage

其餘代碼位置flakeView在主視圖上分配有x,y,寬度和hight屬性。

+0

yes但是當我想讓那個flakeImage與另一個相撞時,我不知道發生了什麼,但是沒有碰到另一個它會發生碰撞,我認爲這是由於容器造成的。你可以解決嗎? – 2011-05-08 12:59:52

+1

你想知道這行代碼做了什麼,我告訴過你我不知道你在說什麼碰撞?你的代碼只是初始化一個視圖! – Cyprian 2011-05-08 13:30:37