iphone - When we create Button frame within for loop then now we want to remove or clean button frame then how can do this? -
when create button frame within loop want remove or clean button frame how can ?
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; }
then remove button frame when want again start loop ....in case if arrya.count 4 4 frame set want next time arrya.count 2 last frame not remove ....what's solution?
ok, method remove buttons in scrollview,
call method when want remove old buttons in scrollview.
-(void) removemybuttons{ for(uiview *v in scrollview.subviews){ if([v iskindofclass:[uibutton class]]){ [v removefromsuperview]; } } }
Comments
Post a Comment