iCarousel stop at user picked index

前端 未结 4 1030
春和景丽
春和景丽 2021-01-11 21:28

EDIT :

I\'m making an app like a Slot Machine, i added iCarousel for the slot object. So I have a button that rotates the iCarou

4条回答
  •  萌比男神i
    2021-01-11 21:50

    Without extending UIButton you can add a unique TAG to the button, getting the tag from the source of the UIEvent.

    IE:

    -(void) buttonSetupMethod {
        for(each item) {
            UIButton * button = [[UIButton alloc] init];
            ... additional setup ...
            button.tag = SOME_UNIQUE_TAG_FOR_BUTTON;
            [button addTarget:self action:@selector(processaction:) forControlEvents:desiredEvents];
            ... retain button ...
         [button release];
        }
     }
    
     -(void) processAction:(id) source
     {
         UIButton * button = (UIButton *) source;
         int tag = button.tag;
         ... conditional logic on specific tag ...
     }
    

    for additional information on passing parameters see : Passing parameters on button action:@selector

提交回复
热议问题