1

ホームボタンの問題のある最初の画像 バー付きの 2 番目の画像

つまり、テーブルビューの最後にまだ到達していないときに、テーブルフッタービューの「ホームに戻る」ボタンが (画面の中央に) 表示されます。最初の写真でわかるように、ホーム ボタンが画面の中央に表示されていますが、これは望ましくありません。テーブルの一番下にとどまらなければなりません。

私の 2 番目の問題は、通常はビューの上部に配置されているセグメント化されたコントロールが、属していない 1 つのセルで再発生することです。cell reusidentifier が無効になっていることを確認しました。

セルにはテキストが入力されているだけなので、セグメント化されたコントロールが表示される理由がわかりません。

編集:コードが追加されました

セルを埋めるためのコード: (その一部ですが、別のセルの別のテキストであり、何も変わりません)

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;

}

追加コメント: セクションが 1 つしかない別のビュー (別のテーブルビュー) で同じフッターを使用していますが、ここではボタンが正しく表示されています。

4

1 に答える 1

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];
        }
     }
 }

うまくいけばうまくいくでしょう。ありがとう。

于 2013-01-11T04:18:31.153 に答える