2017-10-06 4 views
0

테이블 스크롤에 문제가 있습니다. 내 테이블을 아래로 스크롤하면 테이블 위의 버튼이 같은 위치에 그대로 유지되고 필요한 것은 테이블 아래로 스크롤하는 동안 버튼이 사라지는 것입니다. 이 테이블 위의 버튼테이블보기의 스크롤보기 사용자 정의

@implementation Mis_Servicios 


- (void)viewDidLoad { 
    [super viewDidLoad]; 

    [self SetTopBarStyle]; 
    self.title = @"Mis servicios"; 
    barButtonItem=[[UIBarButtonItem alloc]initWithTitle:@"Editar" 
                   style:UIBarButtonItemStylePlain 
                    target:self 
                    action:@selector(toggleEdit)]; 
    self.navigationItem.rightBarButtonItem = barButtonItem; 

    #pragma mark - Table view data source 

    - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{ 

     Cell_Detalles *cell = nil; 
     static NSString *CellIdentifier = @"Cell_registro"; 
     cell =(Cell_Detalles *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 

     NSArray *nib= [[NSBundle mainBundle] loadNibNamed:@"Cell_Detalles_7" owner:self options:nil]; 
     cell = (Cell_Detalles *)[nib objectAtIndex:0]; 

     cell.bt_preguntas.layer.cornerRadius = 20; 
     cell.bt_preguntas.backgroundColor = UIColorFromRGB(0x259026); 
     [cell.bt_preguntas setTitle:@"Alta de servicios" forState:UIControlStateNormal]; 
     [cell.bt_preguntas setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; 
     [cell.bt_preguntas addTarget:self action:@selector(goAltas) forControlEvents:UIControlEventTouchUpInside]; 

     return cell; 
    } 

    - (void)scrollViewDidScroll:(UIScrollView *)scrollView 
    { 
     NSLog(@"%f/%f",self.tableView.contentOffset.y, self.tableView.contentSize.height - self.tableView.frame.size.height); 

     if (self.tableView.contentOffset.y == self.tableView.contentSize.height - self.tableView.frame.size.height){ 
      if (pagenumber < pages) { 
       ++pagenumber; 
       [self ObtenerDatos]; 
      } 

     } 

    } 

입니다 :

내 코드 [cell.bt_preguntas의 setTitle이라는이 "알타 드 SERVICIOS"forState @ UIControlStateNormal]

그리고 이것은이 화면이 어떻게 보이는지에 대한 이미지입니다. Storyboard와 Xib 's를 테이블에 사용하고 있습니다.

enter image description here

답변

1

이 섹션 헤더는 일반 스타일 테이블 뷰에서 작동하는 방법입니다. 좋은 예를 보려면 전화 응용 프로그램의 연락처 탭을 참조하십시오.

단추가 하나만있는 경우 테이블보기의 맨 위에 표시하고 테이블보기를 스크롤 할 때 스크롤하려는 경우 viewForHeaderInSection을 구현하는 대신 단추보기를 테이블로 설정해야합니다 조회수는 tableHeaderView입니다.

viewDidLoad 방법에 다음 코드를 추가합니다 :

NSArray *nib= [[NSBundle mainBundle] loadNibNamed:@"Cell_Detalles_7" owner:self options:nil]; 
Cell_Detalles *cell = (Cell_Detalles *)[nib objectAtIndex:0]; 

cell.bt_preguntas.layer.cornerRadius = 20; 
cell.bt_preguntas.backgroundColor = UIColorFromRGB(0x259026); 
[cell.bt_preguntas setTitle:@"Alta de servicios" forState:UIControlStateNormal]; 
[cell.bt_preguntas setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; 
[cell.bt_preguntas addTarget:self action:@selector(goAltas) forControlEvents:UIControlEventTouchUpInside]; 

self.tableView.tableHeaderView = cell; 

그리고 전체 viewForHeaderInSection 방법을 제거합니다.

+0

예를 보여 주실 수 있습니까? 미안하지만 나는 객관적인 C에서 초보자이고 나는 그것을 한 적이 없어. –

+1

업데이트 된 답변보기 – rmaddy

+0

고마워,이게 내 문제를 해결! –