0

Objective C で X-Code を使用して iPhone アプリを開発しています。テーブルの下部に青色のフッター (ヘッダーと同じ) を追加したいと考えています。

これをどのように達成できるかを提案するのを手伝ってくれる人はいますか。また、このフッターにボタンを追加する方法。

前もって感謝します。

ここに画像の説明を入力

4

5 に答える 5

2

これがお役に立てば幸いです

-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    UIView *viewFotter = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 320, 44)];
    [viewFotter setBackgroundColor:[UIColor blueColor]];
    return viewFotter;
}

しかし、問題は、ボタンのサイズを変更できないことです。ボタンが機能しないためです。

于 2012-11-29T06:27:29.920 に答える
1

このコードを.mファイルに貼り付けて、フッタービューに画像を追加することもできます

-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 44;
}

-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    UIView *viewFotter = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 320, 44)];
    [viewFotter setBackgroundColor:[UIColor blueColor]];
    UIButton *GoBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [GoBtn setTitle:@"GO" forState:UIControlStateNormal];
    GoBtn.frame = CGRectMake(85, 7, 150, 39 );
    [GoBtn addTarget:self action:@selector(GOButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
    [viewFotter addSubview:GoBtn];
    return viewFotter;
}
于 2012-11-29T04:52:28.823 に答える
1
 - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 40;
  }

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
            UIView *footerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 40)];
            footerView.backgroundColor =[UIColor blueColor];
            UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
            [btn setTitle:@"BUTTON" forState:UIControlStateNormal];
            btn.frame = CGRectMake(100, 5, 100, 30 );
            [btn addTarget:self action:@selector(btnClicked:) forControlEvents:UIControlEventTouchUpInside];
            [footerView addSubview:btn];
            return footerView;
    }

   -(void) btnClicked:(id) sender{
     //ur code
    }
于 2012-11-29T04:58:16.147 に答える
0

UIButton必要なコンポーネント ( 、など) を含むカスタム ビューを作成しUIImageView、必要な値を -(UIView*)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section

または、同じビューを tableFooterView に割り当てることもできます

tableView.tableFooterView = yourBlueView;

于 2012-11-29T04:50:02.417 に答える
0

UIButtonをxibのフッターにドラッグするだけでボタンを追加できUITableViewますが、テーブルビューの幅に自動的に割り当てられるため、ボタンのサイズを変更することはできません。しかし、フッターの色について何を言っているのかわかりません。詳しく説明していただけますか。

于 2012-11-29T05:00:47.077 に答える