ビューからすべての UIButtons を削除するのに苦労しています。
それらを for ループに追加しましたがUIScrollView
、後でそれらを削除する必要があります。
それらを追加するには:(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];
}