I know that no one will take the initiative to set up this thing, but everyone must have encountered this problem, the following summary of what may be the situation:
1,self.automaticallyadjustsscrollviewinsets = NO;
This should be the most common and not easy to find cause, the cause is iOS7 in Conttoller new automaticallyadjustsscrollviewinsets This property, when set to Yes (default Yes), If the view contains a unique Uiscrollview or its subclass view, it automatically sets the padding, which allows scroll to occupy the entire view without obscuring the navigation bar.
Ps:ios7 inside the layout problem is a lot of, use AutoLayout time will encounter a lot, probably because iOS7 new join AutoLayout still immature led to it.
2,navigationbar Setup Issues
Although there is a blank at the top of the tableview on the surface, it may actually be caused by Navigationbar setup problems.
self.navigationController.navigationBar.translucent = NO; After this attribute is set to No, the TableView will leave a position of 64.f above the Navigationbar, and there is a small probability that this problem is caused.
3,tableview section Header Height setting problem
This should be a novice encounter more. The cause is the logic of the iOS miracle, and if you set the header (or footer) height to 0, the system will think you're not set and set it to 40.F. So you need to set it to a smaller number:
-(CGFloat) TableView: (UITableView *) TableView heightforheaderinsection: (nsinteger) Section { return0.001f;}
4,tableview header, footer setup issues
It's like 3, isn't it? Don't you see the difference? Let's read it again. This is caused by the header view of the TableView, not the header height of the section.
For TableView, not only each section has Header,tableview as a whole there are also headers and Footer,api as follows:
@property (Nonatomic, Strong, nullable) UIView *tableheaderview; // accessory View for above row content. The default is nil.the not-to-be-confused with section header @property (nonatomic , strong, nullable) UIView *tablefooterview; // accessory View below content. Default is nil. Do not-be-confused with section footer
This header and footer to be more harmonious than the section header, as long as you do not take the initiative to touch it is OK, but if you touch ... Hum, hum ... Will basically be set to 40.f high spacing. This problem can occur if any of the following lines of code are present:
Self.tableView.tableHeaderView = nil;
Self.tableView.tableHeaderView = [[UIView alloc] init];
Self.tableView.tableHeaderView = [[UIView alloc] initwithframe:cgrectzero];
Self.tableView.tableFooterView = nil;
Self.tableView.tableFooterView = [[UIView alloc] init];
Self.tableView.tableFooterView = [[UIView alloc] initwithframe:cgrectzero];
Yes, you do not think wrong, Footerview can not set, footer and header as long as the set of any one will make two places will appear blank. Don't ask me why ...
Of course, what if you really only need one view at a time? Please set the following:(not like silly, build a view Bai, have to use the disgusting things ...) )
Self.tableView.tableHeaderView = [[UIView alloc] Initwithframe:cgrectmake (000.0001f )]; = [[UIView alloc] Initwithframe:cgrectmake (000.0001f)];
Plainly, it has to be set to a very small height, not 0.
TableView on the top of the summary of the basic of these, if you want to block, it is recommended to write these in Basetableviewcontroller, so that you do not have to buckle these things every time. Macro lazy sticky, are common, we should all be able to understand. Navigationbar that, because this thing is not usually set here, it is not a good practice to write in base.
////HLNBASETABLEVIEWCONTROLLER.M//Hln-imdemo////Created by Heiline on 15/8/25.//Copyright (c) 2015 Baidu. All rights reserved.//#import "HLNBaseTableViewController.h"@interfaceHlnbasetableviewcontroller ()@end@implementationHlnbasetableviewcontroller- (void) viewdidload {[Super viewdidload]; Self.tableview=[[UITableView alloc] initWithFrame: (cgrect) {Cgpointzero, kscreensize} Style:_tableviewstyle]; [Self.view AddSubview:self.tableView]; Self.tableView.tableHeaderView= [[UIView alloc] Initwithframe:cgrectmake (0,0, Kscreensize.width,0.0001f)]; Self.tableView.tableFooterView= [[UIView alloc] Initwithframe:cgrectmake (0,0, Kscreensize.width,0.0001f)]; if(Self.navigationcontroller! =Nil) {Self.tableView.height-= Knavbarh +Kstatusbarh; } if(Self.tabbarcontroller! =Nil) { if(Self.navigationController.childViewControllers.count = =1) {Self.tableView.height-=Ktabbarh; }} self.tableview.Delegate=Self ; Self.tableView.dataSource=Self ; Self.automaticallyadjustsscrollviewinsets=NO;}- (void) Dealloc {self.tableView.dataSource=Nil; Self.tableview.Delegate=Nil;}#pragmaMark Table View Data Source and Delegate methods-(Nsinteger) Numberofsectionsintableview: (UITableView *) TableView {return 0;}-(Nsinteger) TableView: (UITableView *) TableView numberofrowsinsection: (nsinteger) Section {return 0;}-(UITableViewCell *) TableView: (UITableView *) TableView Cellforrowatindexpath: (Nsindexpath *) Indexpath {return[[UITableViewCell alloc] init];}-(void) TableView: (UITableView *) TableView Didselectrowatindexpath: (Nsindexpath *) Indexpath {}-(UIView *) TableView: (UITableView *) TableView viewforfooterinsection: (nsinteger) Section {returnNil;}-(UIView *) TableView: (UITableView *) TableView viewforheaderinsection: (nsinteger) Section {returnNil;}-(CGFloat) TableView: (UITableView *) TableView heightforheaderinsection: (nsinteger) Section {return 0.001f;}-(CGFloat) TableView: (UITableView *) TableView Heightforrowatindexpath: (Nsindexpath *) Indexpath {return +. F;}-(CGFloat) TableView: (UITableView *) TableView heightforfooterinsection: (nsinteger) Section {return 0.001f;}@end
"IOS" UITableView cell top blank n method of setting