App崩溃说集合表达式类型UIView*'可能无法响应'countByEnumeratingWithState:object:count"'

LUI*_*LUI 1 iphone objective-c uitableview uiview ios

我有一个UIImageViewtableView内部,并希望在单击该行时以编程方式删除它.

   -(void) tableView:(UITableView *) tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    {

            for (UIView *subview in  tableView)
            {
                if([subview isKindOfClass:[UIImageView class]])
                {
                 [subview removeFromSuperview];
                }
            }
}
Run Code Online (Sandbox Code Playgroud)

当我点击表格行时,应用程序崩溃了.Warning : Collection expression type UIView* may not respond to countByEnumeratingWithState:object:count" 应用程序崩溃提供相同的消息.我错过了什么?我只粘贴了相关的代码部分.

Ani*_*ese 14

代码应该是这样的

for (UIView *subview in  tableView.subviews)
Run Code Online (Sandbox Code Playgroud)