我已經被同時應用程序創建的UIImage子視圖運行將動態創建子視圖IBOutlet中
UIImageView *newBlock = [[UIImageView alloc] initWithImage:
[UIImage imageNamed:@"image.png"]];
newBlock.frame = CGRectMake(0.0, 0.0, 58.0, 58.0);
self.view.userInteractionEnabled = YES;
[self.view addSubview:newBlock];
但是因爲他們沒有在Interface Builder的存在(或至少我無法找到他們)我不能我IBOutlet中連接到新的圖像,以便他們移動基於定時器
timer = [NSTimer scheduledTimerWithTimeInterval:(0.001) target:self selector:@selector(onTimer) userInfo:nil repeats:YES];
pos = CGPointMake(0.0,0.05);
...
- (void) onTimer {
blocks.center = CGPointMake(blocks.center.x+pos.x,blocks.center.y+pos.y)
我一直在考慮通過代碼鏈接它們,而不是在界面生成器中進行鏈接,但是至今未找到有關如何完成的任何細節。任何幫助,將不勝感激。謝謝
如果我的或其他人的答案解決了您的問題,請不要忘記標記爲最佳答案,並將其提升爲使其它問題能夠解決相同問題。如果不添加評論並要求更多幫助 –