0

インターフェイスビルダーで既存のビューにテーブルビューを追加できますか?

私のインターフェースビルダーは次のようになります

ここに画像の説明を入力

しかし、シミュレーターでコードを実行すると、下部のボタンをオーバーレイするため、テーブルがインターフェースビルダーと同じ場所に表示されないことがわかります???

ここに画像の説明を入力

更新...私は一種の進歩を遂げていますが、下部のボタンは隠されています??

ここに画像の説明を入力

FIXED ...アドバイスに従って次のコードを使用します:)

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

UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, 40)];

view.backgroundColor = [UIColor whiteColor];

UIButton *buttonA = [UIButton buttonWithType:UIButtonTypeRoundedRect];
buttonA.frame = CGRectMake(101,5,118,29);
[buttonA setTitle:@"Save & Exit" forState:UIControlStateNormal];
buttonA.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;

[view addSubview:buttonA];

UIButton *buttonB = [UIButton buttonWithType:UIButtonTypeRoundedRect];
buttonB.frame = CGRectMake(254,5,56,29);
[buttonB setTitle:@"Next" forState:UIControlStateNormal];
buttonB.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;

[view addSubview:buttonB];

return view;

}

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

}

4

3 に答える 3

0

次のように、.xib ファイル内のこれらのサブビューに自動サイズ設定を適用します。

ここに画像の説明を入力

また

次の関数を使用してプログラムで変更できます。

UIViewAutoresizing
Specifies how a view is automatically resized.

enum {
   UIViewAutoresizingNone                 = 0,
   UIViewAutoresizingFlexibleLeftMargin   = 1 << 0,
   UIViewAutoresizingFlexibleWidth        = 1 << 1,
   UIViewAutoresizingFlexibleRightMargin  = 1 << 2,
   UIViewAutoresizingFlexibleTopMargin    = 1 << 3,
   UIViewAutoresizingFlexibleHeight       = 1 << 4,
   UIViewAutoresizingFlexibleBottomMargin = 1 << 5
}; 

例は次のとおりです。

  [yourViews.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoResizingFlexibleWidth];
于 2013-02-27T09:39:49.680 に答える
0
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section

データソース メソッドでは、フッター ビュー (「保存して編集」および「次の」UIButton を含む UIView) を返します。

于 2013-02-27T09:41:05.737 に答える
0

テーブルビューのデリゲートとデータソースをファイル所有者に添付したことを確認してください。また、少なくともこれら 2 つのメソッドを実装する必要があります。

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;

// Row display. Implementers should *always* try to reuse cells by setting each cell's reuseIdentifier and querying for available reusable cells with dequeueReusableCellWithIdentifier:
// Cell gets various attributes set automatically based on table (separators) and data source (accessory views, editing controls)

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;

たとえば、このリンクをチェックしてください!

于 2013-02-27T09:33:11.650 に答える