1

I am having two table views TableView1, TableView2. TableView1 contains a list of buttons when I click on any button TableView2 will appear with a list of numbers.

Now when I select any number, that number needs to be displayed in clicked button.

Can anyone help me out with some logic from this as I am new to IOS?

btn_select=[[UIButton alloc]init];
        btn_select.frame=CGRectMake([UIScreen mainScreen].bounds.size.width-245,10,55, 27);
        btn_select.layer.cornerRadius=5;
        btn_select.backgroundColor=[UIColor orangeColor];
        [btn_select addTarget:self action:@selector(NumberButtonclicke:) forControlEvents:UIControlEventTouchUpInside];
        btn_select.tag=indexPath.row;
        [btn_select.titleLabel setTextAlignment:NSTextAlignmentCenter];
        [btn_select setTitle:@"1" forState:UIControlStateNormal];
        [cell addSubview:btn_select];

-(void)NumberButtonclicke:(UIButton *)Sender
{

}
Amr Eladawy
  • 4,193
  • 7
  • 34
  • 52

2 Answers2

0
-(void)NumberButtonclicke:(UIButton *)Sender
{
   CGPoint buttonPosition = [sender convertPoint:CGPointZero toView: Yourtableview];
   NSIndexPath *indexPath = [Yourtableview indexPathForRowAtPoint:buttonPosition];
   NSString *str = [Yourarary objectAtIndex:indexPath.row];  // Your Number list
   NSLog(@"Number is ---%@", str)

 }
Lalit kumar
  • 1,797
  • 1
  • 8
  • 14
0

May be you need only one tableView with collapse and expand Section on click.

Here is the duplicate answer :Expand/collapse section in UITableView in iOS

On Selection of the row , changed the Section Header while reload the table

Community
  • 1
  • 1
Pradeep Kachhawaha
  • 6,589
  • 2
  • 14
  • 13