How to pick the right button.



  • A substantial cycle of a given number of annotations, each annotations adds a button on the veil, after all the buttons are added in the code?

    Example

    for (int i = 0; i < 5; i++) {
    
    UIButton * testView2 = [[UIButton alloc] initWithFrame:CGRectMake(20, hightArray1 + 90 + 37 * i, 280, 35)];
    testView2.backgroundColor = [UIColor whiteColor];
    testView2.layer.cornerRadius = 5.f;
    testView2 addTarget:self action:@selector(actionTestView1) forControlEvents:UIControlEventTouchUpInside];
    [self.mainScrollView addSubview:testView2]; }
    



  • Add the tag button. testView2.tag = 100; Then you can get a teg button: UIButton *button = (UIButton *)[self.view viewWithTag:100];




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2