我想把一個按鈕放到TableView的頁腳上。在iPhone中使用圓形矩形按鈕用於TableView頁腳?
這就是我所做的,我看不到按鈕,但顯示字符串「RESULT」。
我試過了我能想到的一切。但我無法弄清楚什麼是錯的。我需要你幫忙!
- (void)viewDidLoad {
btnSeeResult = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[btnSeeResult setTitle:@"RESULT" forState:UIControlStateNormal];
viewResult = [[UIView alloc] initWithFrame:btnSeeResult.frame];
[viewResult addSubview:btnSeeResult];
self.tableView.tableFooterView = btnSeeResult;
}
-(CGFloat) tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
return viewResult.bounds.size.height;
}
總之,什麼是直接設置像
tableView.tableFooterView = footerView;
頁腳視圖,並使用(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
方法之間的區別?
非常感謝您的回答。在我調用sizeToFit方法後,顯示按鈕。但它的高度完全適合它的字符串,但按鈕會一直拖到左側和右側。我該怎麼辦?該死的我花了幾天的時間用這個按鈕! – SeniorLee 2010-12-25 13:58:51