我怎樣才能做的第一行UITableview是靜態(不滾動)在iPhone SDK?像第一行將是靜態的。UItable視圖不會滾動的第一行我想使用像標題和我已經部分標題
現在第一行是我的標題,我希望它需要靜態意味着不可滾動? 我已經有部分標題,我有行數。
我怎樣才能做的第一行UITableview是靜態(不滾動)在iPhone SDK?像第一行將是靜態的。UItable視圖不會滾動的第一行我想使用像標題和我已經部分標題
現在第一行是我的標題,我希望它需要靜態意味着不可滾動? 我已經有部分標題,我有行數。
只需製作2個tableviews - 一個放在您的視圖頂部,不可打開的單元格,第二個 - 在第一個下面。
這也是一個很好的解決方案.. –
是的。我建議使用簡單的解決方案,而不是大代碼黑客:) –
是的..這是個好主意...一個upvote ..:) –
在下面的代碼,我創建了標題部分的景色,並添加標籤和按鈕..
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
// create the parent view that will hold header Label
if (customView == nil) {
customView = [[UIView alloc] initWithFrame:CGRectMake(10.0, 0.0, 300.0, 44.0)] ;
// create the button object
headerLabel = [[UILabel alloc] initWithFrame:CGRectZero];
headerLabel.backgroundColor = [UIColor clearColor];
headerLabel.opaque = NO;
headerLabel.textColor = [UIColor blackColor];
headerLabel.highlightedTextColor = [UIColor whiteColor];
headerLabel.font = [UIFont boldSystemFontOfSize:20];
headerLabel.frame = CGRectMake(10.0, 0.0, 300.0, 44.0);
// If you want to align the header text as centered
// headerLabel.frame = CGRectMake(150.0, 0.0, 300.0, 44.0);
headerLabel.text = [NSString stringWithFormat:@"Child: Name"];
[customView addSubview:headerLabel];
UIButton *aReportButton = [UIButton buttonWithType:UIButtonTypeCustom];
aReportButton.frame = CGRectMake(270, 3, 38, 38);
[aReportButton setImage:[UIImage imageNamed:@"pdf_document.png"] forState:UIControlStateNormal];
[aReportButton addTarget:self action:@selector(createPDF:) forControlEvents:UIControlEventTouchUpInside];
[customView addSubview:aReportButton];
aVoiceRecordingButton = [UIButton buttonWithType:UIButtonTypeCustom];
aVoiceRecordingButton.frame = CGRectMake(220, 3, 38, 38);
[aVoiceRecordingButton setImage:[UIImage imageNamed:@"microphone_document.png"] forState:UIControlStateNormal];
[aVoiceRecordingButton addTarget:self action:@selector(alertBeforeRecord:) forControlEvents:UIControlEventTouchUpInside];
[customView addSubview:aVoiceRecordingButton];
}
return customView;
}
- (CGFloat) tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return 44.0;
}
在你的情況,你必須提高你的表節頭高度incldude你的節頭和你的第一個UITableViewCell
內容的內容..希望這會有所幫助..
我認爲完全相同,如果我增加標題部分的大小,它將爲我工作,我只是addsubview我的細胞,謝謝讓我試試看謝謝 –
@Ravi你的問題得到解決? –
需要採取自定義視圖的第一tableviewCell和頭添加子視圖sectionView 在
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
在標題視圖 正下方設置自定義視圖框,並正確設置標題視圖的「否」。 之後在標題視圖中添加子視圖自定義視圖。
希望這有助於。
我的想法是你可以有一個子表內部分頭的子視圖,這樣你就可以把你想要的東西和其餘的細胞將滾動.. –
我可以張貼示例代碼,如果你需要.. –
是,請把它,但我的問題是,我的表的第一行將由indexpath的UITableview cellfor行,現在如果我把該單元格作爲我的部分hederview的子視圖仍然不可見? 需要幫助,如果你有任何代碼,請放在這裏謝謝 –