2

の最後にさらにロードボタンを追加したいと思いますUITableview。Instagramのload-moreボタンと同じ機能があります。これが写真です。

写真

だから私の質問は、最後にそれを追加する方法UITableviewですか?テーブルビューはスクロール可能であるため、ボタンに動的な位置を設定する方法がわかりません。

前もって感謝します。

4

3 に答える 3

7

空の UIViewUIView *v = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 70)]; を作成します: ボタンを作成します:

UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button setTitle:@"Load More" forState:UIControlStateNormal];
[button addTarget:self action:@selector(buttonLoadMoreTouched) forControlEvents:UIControlEventTouchUpInside];
[button sizeToFit];

1 のビューのサブビューとしてボタンを追加します。

[v addSubview:button];

テーブルのtableFooterViewプロパティを 1 からのビューに設定します。

self.myTableView.tableFooterView = v;
于 2012-06-24T07:20:26.870 に答える
0

すべてのUITableViewにはfooterViewプロパティがあります。カスタムfooterViewを作成し、プロパティを設定するだけです

@property(nonatomic, retain) UIView *tableFooterView
于 2012-06-24T07:14:47.447 に答える
0
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section

上記の方法でボタンを追加し、以下の方法でフッターを必要なサイズに設定できます

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

お役に立てれば。

于 2014-05-24T08:31:05.713 に答える