使用Storyboard时如何使UITable标题贴在屏幕顶部? [英] How to make UITable header stick to the top of the screen when using Storyboards?
本文介绍了使用Storyboard时如何使UITable标题贴在屏幕顶部?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用这篇文章制作了标题: StoryBoards中的表头视图
I've made header using this post: Table Header Views in StoryBoards
但我无法在滚动时将标题粘贴(修复)到屏幕顶部。
But i am unable to make header stick (fix) to the top of the screen while scrolling.
如何可以实现吗?
PS表样式很简单,当我厌倦了重载 viewForHeaderInSection
并返回标题视图的出口时,它变得更糟。
P.S. Table style is plain, and when i tired to overload viewForHeaderInSection
and returned outlet for header view, it just got worse.
提前致谢!
推荐答案
我能够这样做(至少在iOS 6中)这样,不要知道为什么这个东西有效:)
I was able to do it (at least in iOS 6) like this, don't know why this thing works:)
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
if(self.headerManualView == nil) {
//allocate the view if it doesn't exist yet
headerManualView = [[UIView alloc] init];
//create the button
UITextField *txtField = [[UITextField alloc] initWithFrame:CGRectMake(10, 3, 250, 44)];
//the button should be as big as a table view cell
txtField.borderStyle = UITextBorderStyleRoundedRect;
//set action of the button
//[txtField addTarget:self action:@selector(removeAction:) forControlEvents:UIControlEventTouchUpInside];
//add the button to the view
[headerManualView addSubview:txtField];
}
//return the view for the footer
return headerManualView;
}
这篇关于使用Storyboard时如何使UITable标题贴在屏幕顶部?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文