iphone - How to realize action on multiple objects -
i have values of uibuttons. every button have created dynamically, code:
-(void)addnewtable: (nsstring *) tablepic: (nsstring *) addedtype { createdtable *ct = [[createdtable alloc] init]; cfuuidref newuniqueid = cfuuidcreate(kcfallocatordefault); nsstring * uuidstring = (__bridge nsstring*)cfuuidcreatestring(kcfallocatordefault, newuniqueid); cfrelease(newuniqueid); uiimage *tableimage = [uiimage imagenamed: tablepic]; cgrect framebtn = cgrectmake(160.0f, 160.0f, tableimage.size.width, tableimage.size.height); uibutton *button = [uibutton buttonwithtype:uibuttontypecustom]; [button setbackgroundimage: tableimage forstate:uicontrolstatenormal]; [button setframe:framebtn]; [button addtarget:self action:@selector (draggedout:withevent::) forcontrolevents:uicontroleventtouchdraginside]; [button settitle: [nsstring stringwithformat:@"%d", tables.count] forstate: uicontrolstatenormal]; ct.id = [uuidstring lowercasestring]; ct.posx = 160; ct.posy = 160; ct.isactive = true; ct.index = button.titlelabel.text; ct.picture = [nsstring stringwithformat:@"tables/%@", tablepic]; ct.type = addedtype; ct.angle = 0.0; [tables addobject:ct]; [hallview addsubview:button]; }
createdtable - nsobject string params of created buttons.
as can see, i'm adding selector every created button. can move every button selector. here it's code:
- (ibaction)draggedout: (id)sender withevent: (uievent *) event: (nsset *)touches { createdtable = [tables objectatindex: selected.[titlelabel.text intvalue]] uibutton *selected = (uibutton *)sender; selected.center = [[[event alltouches] anyobject] locationinview:hallview]; ct.posx = selected.center.x; ct.posy = selected.center.y; // here i'm changing params in ct. }
now need realize multi-select (select value of buttons tapping on them, make king of group) , after need move group (all selected buttons) 1 single object.
any suggestions how realize it?
when user select multiple buttons 1 one , mark them selected buttons changing background image . when user starts dragging 1 of selected button create bigger view (with clear background color) , add copies(new buttons alike selected buttons) of selected buttons , add them on bigger view . changing position of original button (button getting dragged) , change position of bigger view . give , feel selected button getting dragged . bigger view dragging stopped remove original selected buttons main view .
hope you.
Comments
Post a Comment