我有一個UIImageView
一個的tableView內,要在單擊行時以編程方式刪除它應用程序崩潰說集合表達式類型的UIView * countByEnumeratingWithState」可能不響應「:對象:伯爵「」
-(void) tableView:(UITableView *) tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
for (UIView *subview in tableView)
{
if([subview isKindOfClass:[UIImageView class]])
{
[subview removeFromSuperview];
}
}
}
當我點擊應用程序崩潰的錶行。Warning : Collection expression type UIView* may not respond to countByEnumeratingWithState:object:count"
同一封郵件遞交該應用程序崩潰。我在這裏錯過了什麼?我只粘貼代碼的相關部分。
這實際上回答我的問題,以及!但我不確定爲什麼。你有什麼見解嗎? – narner
@narner在他試圖刪除一個tableView的子視圖的問題,但他錯誤地寫了'for(UIView * subview in tableView)'迭代。這裏'tableView'是一個單一的視圖。我們應該得到它的子視圖'tableView.subviews'。 –
啊,謝謝你! – narner