
問題出現的原因:創建tableView時使用的style是UITableViewStylePlain
解決辦法:
在創建tableView時,self.automaticallyAdjustsScrollViewInsets = NO;
官方文檔是這么寫的:
@property(nonatomic, assign) BOOL automaticallyAdjustsScrollViewInsets
Discussion
Default value is
YES
, which allows the view controller to adjust its scroll view insets in response to the screen areas consumed by the status bar, navigation bar, and toolbar or tab bar. Set to
NO
if you want to manage scroll view inset adjustments yourself, such as when there is more than one scroll view in the view hierarchy.
原因二:創建tableView時使用的style是UITableViewStyleGrouped,那么會為footer自動預留位置。
由於此原因,使用上面方法的話是沒有用的。需要設置footer的height值為0.001,及無限接近0但是直接賦值為0的話也沒有作用。
-(CGFloat)tableView:(UITableView *)tableView heightaForFooterInSection:(NSInteger)section{
return 0.001;
}
具體原因還沒沒明白。