2017-05-04 1 views
1

두 개의 TableView1, TableView2가 있습니다. TableView1에는 임의의 버튼을 클릭 할 때 버튼 목록이 포함되어 있습니다. TableView2에는 숫자 목록이 나타납니다.단추 제목이있는 TableView 색인

이제 번호를 선택하면 해당 번호를 클릭 한 버튼에 표시해야합니다.

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 
{ 

} 

답변

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) 

} 
+0

number.text =있는 NSString stringWithFormat를 다시하면서 섹션 헤더 변경 .row + 1]; 나는 가지고 싶지 않아. –

+0

배열이없는 경우. 귀하의 코드 그것은 당신이 선택 행 번호를 줄 것이다 –

+0

클릭하면 번호 tableview에서 indexpath에서 행을 선택 않았다 클릭 버튼 텍스트는 클릭 인덱스 번호로 변경해야합니다 –

0

당신이 붕괴 하나만있는 tableView이 필요 클릭에 섹션을 확장 할 수 있습니다. 여기

가 중복 해답 @ "%의 LD"(길이) indexPath : 행의 선택에 Expand/collapse section in UITableView in iOS

테이블