2012-04-07 7 views
0

下ではない、私は私のテーブルビューにフッターを追加するには、このメソッドを実装しているのUITableViewCellを作る:場所のUITableViewのフッターにボタンとそうフッター

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

は、これが結果です:

1)私は、テーブルビューのフッター内のボタンを追加したいと思いますが、私はボタンをドラッグすると:enter image description here

は今、あなたが見る、2つの問題がありますストーリーボードの制御、それは動作しません。そこにボタンを追加するには?

2)ご覧のとおり、フッターは透明で、その下に表ビューセルが表示されます。私はフッターの下に細胞がないようにしたいと思います(最後の目に見える細胞はフッターの上にあるでしょう)。第二に、私はフッターが透明でないようにしたい。

私はXcode 4.2とSnow Leopardを使用しています。

答えて

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

は、委任方法です。代わりにテーブルのsectionFooterHeightプロパティにアクセスしてください。

ボタンを追加するには、カスタムビューをフッターに追加することをお勧めします。 tableFooterViewにアクセスして、カスタムビューを割り当てることができます。

+0

私はそれをしました。私はsectionFooterHeightを使用しましたが、フッターはまったく表示されません。 –

1

あなたはのtableViewを使用することができます。viewForFooterInSection:フッター

1

増加下tableviewsのcontenteサイズ

UIEdgeInsets contentInset = self.tableView.contentInset; 
contentInset.bottom = 50.0f; // **the height of the footer** 
self.tableView.contentInset = contentInset; 
+0

self.myToolbarとは何ですか? –

+0

は、任意の高さにすることができます。 – FoJjen

2

使用この機能を表

- (UIView *) createViewForTableFooter 
{ 
    CGRect footerRect = CGRectMake(0, 0, self.view.frame.size.width, 60); 
    UIView *tableFooter = [[[UIView alloc] initWithFrame:footerRect] autorelease]; 
    tableFooter.backgroundColor = [UIColor clearColor]; 

    UIButton* verifyButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; 
    [verifyButton setTitle:WNLocalizedString(@"Verify",@"") forState:UIControlStateNormal]; 
    [verifyButton.titleLabel setFont:[UIFont boldSystemFontOfSize:20]]; 
    [verifyButton addTarget:self action:@selector(verifyBtnTapped:)forControlEvents:UIControlEventTouchUpInside]; 
    verifyButton.autoresizingMask = UIViewAutoresizingFlexibleWidth; 
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { 
     [verifyButton setFrame:CGRectMake(44, 10, self.view.frame.size.width - 88, 37)]; 
    }else { 
     [verifyButton setFrame:CGRectMake(10, 10, self.view.frame.size.width - 20, 37)]; 
    } 
    [tableFooter addSubview:verifyButton]; 

    return tableFooter; 
} 
のためのフッタビューを作成するにボタンを追加する方法を

viewDidLoadメソッドで次のようにこの関数を使用してください。

yourTableObjectName.tableFooterView = [self createViewForTableFooter];