On the issue of Uitableviewcontroller being covered by status bar (IOS SDK 8.3)

Source: Internet
Author: User

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!

    1. 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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.