2013-01-11 2 views
1

first image with home button problem second image with barjQuery과 및 셀 보여주는 내용

내 tableview에, 즉, tablefooterview에서 "이동 홈"버튼 (화면의 중앙에)를 보여주는 두 개의 문제가있는 경우 tableview의 끝에 아직 도달하지 않았습니다. 첫 번째 사진에서 볼 수 있듯이 화면의 가운데에 홈 버튼이 나타나고 싶지 않습니다. 테이블의 맨 아래에 있어야합니다.

두 번째 문제는 일반적으로 뷰의 맨 위에 위치하는 분할 컨트롤입니다. 속하지 않는 하나의 셀에서 재발생합니다. 나는 셀 재사용이 불가능하다는 것을 확인했다.

셀은 텍스트로 채워지므로 세분화 된 컨트롤이 표시되는 이유를 알 수 없습니다.

편집 : 코드 세포를 채우는

코드를 추가 : 바닥 글에 대한

if(indexPath.section == 2){ 
    [[cell textLabel] setTextAlignment:UITextAlignmentLeft]; 
    [[cell textLabel] setText:_actor.actorBeschrijving]; 

    if([[cell textLabel] text] == nil) 
    { 
     [[cell textLabel] setText:@"Druk om een beschrijving toe te voegen"]; 
     [[cell textLabel] setTextColor:[UIColor grayColor]]; 

    } 
} 


if(indexPath.section == 3 && control.selectedSegmentIndex == 1){ 
    if([has count] == 0){ 

     [[cell textLabel] setTextAlignment:UITextAlignmentLeft]; 
     [[cell textLabel] setText: @"Voeg een nieuw object toe"]; 
    } 
    else{ 

     if(indexPath.row < [has count]){ 


      AnObject *object = (AnObject*)[has objectAtIndex:indexPath.row]; 
      [[cell textLabel] setTextAlignment:UITextAlignmentLeft]; 
      [[cell textLabel] setText:object.objectNaam]; 

     } 

     if(indexPath.row == [has count]){ 
      [[cell textLabel] setTextAlignment:UITextAlignmentLeft]; 
      [[cell textLabel] setText:@"Voeg een nieuw object toe"];  
     } 
    } 

} 
if(indexPath.section == 3 && control.selectedSegmentIndex == 3){ 

    if([isResponsible count] == 0){ 

     [[cell textLabel] setTextAlignment:UITextAlignmentLeft]; 
     [[cell textLabel] setText: @"Voeg een nieuwe goal toe"]; 
    } 
    else{ 

     if(indexPath.row < [isResponsible count]) { 


      Goal *goal = (Goal*)[isResponsible objectAtIndex:indexPath.row]; 
      [[cell textLabel] setText:goal.goalNaam]; 

     } 


     if(indexPath.row == [isResponsible count]){ 
      [[cell textLabel] setTextAlignment:UITextAlignmentLeft]; 
      [[cell textLabel] setText: @"Voeg een nieuwe goal toe"]; 


     } 
    } 

} 

코드 (그것의 단지 조각을하지만 다른 셀에서 바로 다른 텍스트의, 아무것도 변경되지 않습니다) :

@property (nonatomic, retain) IBOutlet UIView *myFooterView; 


-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section 

{ 
    if(section == tableView.numberOfSections - 1) 
    return 50.0f; 

} 

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

if(myFooterView == nil) { 
    //allocate the view if it doesn't exist yet 
    myFooterView = [[UIView alloc] init]; 


    //create the button 
    UIButton *footButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; 

    [footButton setFrame:CGRectMake(110, 10, 100, 30)]; 

    //set title, font size and font color 
    [footButton setTitle:@"Go Home" forState:UIControlStateNormal]; 
    [footButton.titleLabel setFont:[UIFont boldSystemFontOfSize:18]]; 

    //set action of the button 
    [footButton addTarget:self action:@selector(clickPressed:) 
     forControlEvents:UIControlEventTouchUpInside]; 

    //add the button to the view 
    [myFooterView addSubview:footButton]; 
} 

//return the view for the footer 
return myFooterView; 

}

내선 ra 코멘트 : 하나의 섹션 만있는 다른 뷰 (다른 테이블 뷰)에서 같은 바닥 글을 사용하고 있습니다. 여기에서는 버튼이 올바르게 표시됩니다.

+0

버튼을 바닥 글보기와 'cellForRowAtIndexPath' 내의 코드에 추가 할 수 있습니까? –

+0

코드를 추가했습니다. 한번보세요. – Fuzej

답변

0

안녕하세요 정적으로 배치하는 대신 세그먼트 제어 & 버튼을 동적으로 코딩 할 수 있습니다.

예 :

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
    static NSString *CellIdentifier = @"MyIdentifier"; 
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] ; 
    cell.selectionStyle = UITableViewCellSelectionStyleNone; 

    if (indexPath.section == 0) 
    { 
     if (indexPath.row == 0) 
     { 
      //Dynamic Code for Segmented Control 
      [cell.contentView addSubview:segementedControl]; 
     } 
    } 

    ----------- 

    if (indexPath.section == 4) // For Eg. 5 is the last section. You can use your own 
    { 
     if (indexPath.row == 0) 
     { 
      //Dynamic Code for Button 
      [cell.contentView addSubview:button]; 
     } 
    } 
} 

잘하면 작동합니다. 감사.

+0

이것이 내 질문과 관련이 있다는 것을 이해하지 못합니까? 나는 그들 중 하나가 내 세포에있는 것을 원하지 않는다. – Fuzej

+0

그래서 Top of the View에서 UISegmented Control을 설정할 수 있습니다. 그런 다음 View에 TableView를 설정하고 맨 아래에 Add Button을 추가하십시오. 전체 크기로 표보기를 사용할 필요가 없습니다. –

+0

예 : Segmented Control 10 & height -> 40으로 시작합니다. 따라서 TableView는 -> 60으로 시작하여> 260 정도의 높이를 취합니다. 그런 다음 하단에 Button을 추가하십시오. 그래서 스크롤은 TableView에서만 사용 가능하게됩니다. 감사. –