for ループ内でボタン フレームを作成するときに、ボタン フレームを削除またはクリーンアップするにはどうすればよいでしょうか。
for(int i=0 ;i<(self.WebService->ptr1).count ;i++)
{
Test1=[[UIButton alloc]initWithFrame:CGRectMake(x,y,w,h)];
[Test1 addTarget:self action:@selector(TestDescription1:)forControlEvents:UIControlEventTouchUpInside];
Test1.tag=i;
NSLog(@"test =%d",Test1.tag);
NSString *s1 =[NSString stringWithFormat:@"%@",[[self.WebService->ptr1 objectAtIndex:i]valueForKey:@"Description"]];
NSLog(@"s1 =%@",s1);
NSString *s2 =[NSString stringWithFormat:@"%@",[[self.WebService->ptr1 objectAtIndex:i]valueForKey:@"TestId"]];
NSLog(@"s2 =%@",s2);
[TestID addObject:s2];
NSLog(@"test id=%@",TestID);
[Test1 setTitle:s1 forState:UIControlStateNormal];
[scrollview addSubview:Test1];
UITapGestureRecognizer *tap=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(TestDescription1:)];
[Test1 addGestureRecognizer:tap];
Test1.userInteractionEnabled=YES;
tap.numberOfTapsRequired = 1;
y=y+40;
}
次に、再び for ループを開始したいときにボタン フレームを削除します ....この場合、ARRYA.count が 4 の場合、4 つのフレームが設定されますが、次回は Arrya.count が 2 ですが、最後のフレームは削除されません.. ..解決策は何ですか?