Usually we do a uitableviewcontroller (hereinafter referred to as TVC) directly open, in the absence of Navigationcontroller will be like this
The question is, do you want to add a Uinavigationcontroller?
Or like others do not need uitableviewcontroler but in main storyboard inside build a Uiviewcontroller + UITableView Move Down 20px?
Tell you about a method I've recently implemented:
#define Baritemheight- (void) Viewdidload {[SuperViewdidload];CGRectframe = Self. View. Frame; Frame. Size. Height= Baritemheight;Uinavigationbar*navigationbar = [[UinavigationbarAlloc] Initwithframe:frame]; Uinavigationitem *navigationitem = [[Uinavigationitem alloc] initwithtitle:@"Active Group"];Uibarbuttonitem*leftbutton = [[UibarbuttonitemAlloc] Initwithbarbuttonsystemitem:uibarbuttonsystemitemdone target: SelfAction@selector(Actiondown)];Uibarbuttonitem*rightbutton = [[UibarbuttonitemAlloc] Initwithbarbuttonsystemitem:uibarbuttonsystemitemcancel target: SelfAction@selector(Actioncancel)]; [Navigationbar Pushnavigationitem:navigationitem Animated:YES]; [Navigationitem Setleftbarbuttonitem:leftbutton]; [Navigationitem Setrightbarbuttonitem:rightbutton]; Self. TableView. Tableheaderview= Navigationbar;} -(void) actiondown{[ SelfDismissviewcontrolleranimated:YEScompletion:^{//Balabalabala ...}];} -(void) actioncancel{[ SelfDismissviewcontrolleranimated:YESCompletion:Nil];}
Easy!
- Since the Navigatebar is part of the TableView, when the finger is sliding, the Navigatebar will move with the movement, if the hope Navigatebar not move, then the
- (void)viewDidLoad{...}
The contents of the inside are removed
Then, in
-(void)viewDidAppear:(BOOL)animated{}
Add something like this, to why add here, probably because some of the internal controls are not ready for viewdidload.
-(void) Viewdidappear: (BOOL) animated{CGRectframe = Self. View. Frame; Frame. Origin. Y+ = Baritemheight; Frame. Size. Height-= Baritemheight; Self. View. Frame= frame; Frame. Origin. Y=0; Frame. Size. Height= Baritemheight;Uinavigationbar*navigationbar = [[UinavigationbarAlloc] Initwithframe:frame]; Uinavigationitem *navigationitem = [[Uinavigationitem alloc] initwithtitle:@"Active Appointment"];Uibarbuttonitem*leftbutton = [[UibarbuttonitemAlloc] Initwithbarbuttonsystemitem:uibarbuttonsystemitemdone target: SelfAction@selector(Actiondown)];Uibarbuttonitem*rightbutton = [[UibarbuttonitemAlloc] Initwithbarbuttonsystemitem:uibarbuttonsystemitemcancel target: SelfAction@selector(Actioncancel)]; [Navigationbar Pushnavigationitem:navigationitem Animated:YES]; [Navigationitem Setleftbarbuttonitem:leftbutton]; [Navigationitem Setrightbarbuttonitem:rightbutton]; [ Self. View. SuperviewAddsubview:navigationbar];}
Thank you for me!
Reprint don't forget to send me the link
On the issue of Uitableviewcontroller being covered by status bar (IOS SDK 8.3)