ikbal
ikbal

Reputation: 1174

How to get index of multiple scrollview in iOS

i have horizontal and vertical scrollview, for example one scrollview have four button and and second scrollview have six button and more so, when i click on any button then got index of last scrollview view, i already using tag.

my problem is for example i click on third scroll then i want both tag third scroll tag and specific button tag.

enter image description here

Upvotes: 0

Views: 358

Answers (1)

KKRocks
KKRocks

Reputation: 8322

  1. first tag of scrollview in storyboard .
  2. set tag to button dynamically.(while create button or add button to scrollview)
  3. track your index as below :

    - (IBAction)clickonbutton:(UIButton *)sender {
    
    UIScrollView* yourscrollview = (UIScrollView*)[sender superview]; // track your scrollview as per your view hierarchy
    
     NSLog(@"%ld",(long)yourscrollview.tag);
    
     NSLog(@"clicked button tag%@",sender.tag);
    
    }
    

Upvotes: 1

Related Questions