這是我的代碼:ios-「交換」UIViews可能嗎?
if([pantallas objectForKey:par]){
UIView *vista= [[UIView alloc] initWithFrame:self.Botones.frame];
vista.backgroundColor= [UIColor brownColor];
CGSize la= CGSizeMake(50,60);
int cuantos= [part2 count];
NSArray *arr= [COLGenerales tileN:cuantos RectsOfSize:la intoSpaceOf:vista.frame withMaxPerRow:5 spaceVertical:10 spaceHorizontal:10];
for(int j=0; j<cuantos; j++){
UIButton *bot= [[UIButton alloc] initWithFrame:[[arr objectAtIndex:j] CGRectValue]];
bot.tag=j;
bot.titleLabel.text=par;
bot.titleLabel.hidden=true;
bot.imageView.image = [UIImage imageNamed:[[part2 allKeys] objectAtIndex:j]];
[bot addTarget:self action:@selector(registrar:) forControlEvents:UIControlEventTouchDown];
[vista addSubview:bot];
}
[pantallas setObject:vista forKey:par];
self.Botones= vista;
}else{
self.Botones= [pantallas objectForKey:par];
}
Botones是嵌入到視圖的簡單視圖這類控制(第一通過筆尖文件發起的),COLGenerales的類方法返回編碼爲NSValues CGRects的陣列,和註冊:是一種本地方法。
一切都正確設置(我用調試器徹底檢查了這一點)。視圖被成功創建,設置並添加到字典中。
但是,我絕對沒有得到實際的屏幕更改。我甚至包含了背景顏色變化,以檢查它是否不是按鈕的某種問題。沒有。任何建議的解決方案?
此代碼在哪裏存在,以及它如何被調用?此視圖何時添加到屏幕視圖? – 2013-04-03 19:50:27
在詳細視圖的控制器的函數內,這由主視圖調用。 Botone本身就是細節場景的一部分(其IBOutlet屬性設置爲「strong」),並且我認爲改變它的值應該反映在屏幕上的內容上。 – 2013-04-03 20:15:58