Skip to content

Click Event and Listener (Objective C)

Weiping Huang edited this page May 13, 2017 · 2 revisions

Listener for clicking each button or animation-states. Check the demo for more details.

Swift | Objective-C

Listener in Each Builder

You can add a simple clicked-block for each boom-button by adding listeners to each builder of them.

for (int i = 0; i < self.bmb.pieceNumber; i++)
{
    VHSimpleCircleButtonBuilder *builder = [VHSimpleCircleButtonBuilder builder];
    
    // Event block when the boom-button corresponding the builder itself is clicked.
    builder.clickedBlock = ^(int index) {
        // the boom-button is clicked
    };

    [self.bmb addBuilder:builder];
}

Listener for BMB

If you want to manager all the click events in one method, you can use VHBoomDelegate:

...

bmb.boomDelegate = self;

...

- (void)boomMenuButton:(VHBoomMenuButton *)bmb didClickBoomButtonOfBuilder:(VHBoomButtonBuilder *)builder at:(int)index
{
    // If you have implement clickedBlocks for boom-buttons in builders,
    // then you shouldn't add any listener here for duplicate callbacks.
    
    // self.buttonLabel.text = builder.normalImageName;
}

- (void)boomMenuButtonDidClickBackground:(VHBoomMenuButton *)bmb
{
    self.animationLabel.text = @"Click background!!!";
}

- (void)boomMenuButtonWillReboom:(VHBoomMenuButton *)bmb
{
    self.animationLabel.text = @"Will RE-BOOM!!!";
}

- (void)boomMenuButtonDidReboom:(VHBoomMenuButton *)bmb
{
    self.animationLabel.text = @"Did RE-BOOM!!!";
}

- (void)boomMenuButtonWillBoom:(VHBoomMenuButton *)bmb
{
    self.animationLabel.text = @"Will BOOM!!!";
}

- (void)boomMenuButtonDidBoom:(VHBoomMenuButton *)bmb
{
    self.animationLabel.text = @"Did BOOM!!!";
}

State of BMB

Get the states of BMB by:

bmb.isAnimating  // Whether BMB is animating.
bmb.isBoomed     // Whether BMB is boomed.
bmb.isReBoomed   // Whether BMB is re-boomed.

Home
Chapters

  1. Basic Usage
  2. Simple Circle Button
  3. Text Inside Circle Button
  4. Text Outside Circle Button
  5. Ham Button
  6. Share Style
  7. Custom Position
  8. Button Place Alignments
  9. Different Ways to Boom
  10. Ease Animations for Buttons
  11. Different Order for Buttons
  12. Other Animations Attributes for Buttons
  13. Click Event and Listener
  14. Control BMB
  15. Use BMB in Navigation Bar
  16. Use BMB in Table View
  17. Attributes for BMB or Pieces on BMB
  18. Cache Optimization & Boom Area
  19. Change Boom Buttons Dynamically
  20. Blur Background & Tip
  21. Fade Views
  22. Structure of BMB
  23. Version History
Clone this wiki locally