我很难从视图中删除所有 UIButtons 。
我已将它们添加到UIScrollView
for 循环中,稍后我需要删除它们。
所以添加它们:(在 cocos2d 场景中)
sview = [[UIScrollView alloc]
initWithFrame:[[UIScreen mainScreen] bounds]];
......
for(int i =0; i<[assets count]-1; i++)
{
UIImage *thumb= [assets objectAtIndex:i];
UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];
[sview addSubview:button];
.......
[[[CCDirector sharedDirector] view] addSubview:sview];
并删除它们:
[((UIView *)sview) removeFromSuperview]; //which usually works but no now .
我以后如何在所有这些按钮上运行并删除它们?我没有指向它们的链接,我想在视图中的所有按钮上运行..
编辑:尝试过但没有成功
for (int i=0; i<[assets count];i++)
{
UIButton *myButton = (UIButton *)[sview viewWithTag:i];
[((UIView *)myButton) removeFromSuperview];
}