How to get fixed number of subview from all subview of scrollview using fast enumeration in ios -
how select prepare number of subview subview of scrollview using fast enumeration in ios?
do following: 1.give tags buttons when creating them.for example:
uibutton *button = [uibutton buttonwithtype:uibuttontyperoundedrect]; button.tag = 1; [button addtarget:self action:@selector(amethod:) forcontrolevents:uicontroleventtouchupinside]; [button settitle:@"show view" forstate:uicontrolstatenormal]; button.frame = cgrectmake(80.0, 210.0, 160.0, 40.0); [view addsubview:button];
2.do not understand why want utilize fast enumeration, can simple buttons by:
uibutton *btn1 = (uibutton *)[self.yourscrollview viewwithtag:1]; uibutton *btn2 = (uibutton *)[self.yourscrollview viewwithtag:2]; uibutton *btn3 = (uibutton *)[self.yourscrollview viewwithtag:3]; uibutton *btn4 = (uibutton *)[self.yourscrollview viewwithtag:4]; uibutton *btn5 = (uibutton *)[self.yourscrollview viewwithtag:5];
2.if requirement using fast enumeration, take nsmutablearray hold buttons:
nsmutablearray *arrayofbuttons = [[nsmutablearray alloc] initwithcapacity:5]; (id btn in self.yourscrollview.subviews) { @autoreleasepool { if (btn.tag > 0 || btn.tag<=5) { [arrayofbuttons addobject:btn]; } } }
hope help you.
ios scrollview subview nsfastenumeration
No comments:
Post a Comment