I have created two buttons with pagescrolling. Now by clicking on one button the other button should be visible. How would it possible to get index of the other button when performing action method of the current button?
Here is the code for creating the buttons:
for (int i = 0 ; i < numberOfPages ; i++)
{
pageFrame = CGRectMake(i * scrollView.bounds.size.width, 0.0f, scrollView.bounds.size.width, 416) ;
btnSettingButton=[[UIButton alloc]initWithFrame:pageFrame ];
[ btnSettingButton setFrame:CGRectMake(i * (scrollView.bounds.size.width)+50, 260, 20, 20)];
btnSettingButton.tag=i;
[btnSettingButton setImage:[UIImage imageNamed:@"Settings Icon.png"] forState:UIControlStateNormal];
[scrollView addSubview:btnSettingButton];
[btnSettingButton setHidden:YES];
// [btnSettingButton release];
UIButton *btnCheckButton=[[UIButton alloc]initWithFrame:pageFrame ];
[ btnCheckButton setFrame:CGRectMake(i * (scrollView.bounds.size.width)+250, 260, 20, 20)];
[btnCheckButton setImage:[UIImage imageNamed:@"NO.png"] forState:UIControlStateNormal];
[btnCheckButton addTarget:self action:@selector(checkBoxClicked:) forControlEvents:UIControlEventTouchUpInside];
// [btnCheckButton addTarget:self action:@selector(changePage:) forControlEvents:UIControlEventTouchUpInside];
[scrollView addSubview:btnCheckButton];
[btnCheckButton release];
UIButtonhas atagproperty. You can set counter to tag and then check which button was clicked.Action:
In order to find button on your view use method
viewWithTag: