Iphone/ios to open the relevant position adjustment summary of personal hotspot

Source: Internet
Author: User

The winter solstice has arrived, Christmas near, the recent company project is too many, three or four projects repeatedly switch really let people burn, while today a little empty, the maintenance of the three projects smoothly sent out, just can strands of ideas, record the recent problems encountered. Say no hurry that is false, customer day by day is really upsetting, but back to think also really difficult, so still convinced themselves seriously to their feedback of a problem, try to make them satisfied also let their satisfaction. There is a sentence how to say, finally finished, fortunately I did not give up. Haha, gossip not much to say, talk about recently encountered a solution to the problem, caused by hot spots in the status bar position changes caused by the custom bottom bar position dislocation problem.

About the hot posts online indeed a lot, also gave a lot of solutions. iphone as a personal hotspot and there is a connection, the system status bar will be more than one line of hot connection prompt bar "Personal hotspot: * Connection", vertical pressure 20pt; When all connections are disconnected, the hotspot bar disappears and the vertical height returns to normal.

1. System Status Bar

App_statusbar_height=[uiapplication sharedapplication].statusbarframe.size.height, including height of hotspot bar (if any), standard height of 20pt , when there is a personal hotspot connection, the height is 40pt.

iOS system version

#define system_version [[[Uidevice Currentdevice] systemversion] Doublevalue]

Standard system Status Bar height

#defineSys_statusbar_height20
Hotspot Bar Height
#defineHotspot_statusbar_height20
Navigation bar (Uinavigationcontroller.uinavigationbar) height
#defineNavigationbar_height44
Toolbar (uinavigationcontroller.uitoolbar) Height
#defineToolbar_height44
tab bar (Uitabbarcontroller.uitabbar) height
#defineTabbar_height44
App_statusbar_height=sys_statusbar_height+[hotspot_statusbar_height]
#defineApp_statusbar_height(Cgrectgetheight ([uiapplication sharedapplication].statusbarframe))
Determine if there is a hotspot bar based on App_statusbar_height
#defineis_hotspot_connected(app_statusbar_height== (sys_statusbar_height+hotspot_statusbar_height)? Yes:no)
Standard system Status bar height + navigation bar height when no hotspot bar
#defineNormal_status_and_nav_bar_height(Sys_statusbar_height+navigationbar_height)
Real-time system status bar height + navigation bar height, if there is a hotspot bar, its height is included in the App_statusbar_height.
#defineStatus_and_nav_bar_height(App_statusbar_height+navigationbar_height)

2.uiviewcontroller.view.bounds.height
    • System_version < 7.0,uiviewcontroller.view.bounds.height contains the height of the navigation bar, does not contain the system status bar height, and does not include the Hotspot bar (if any).
    • The system_version≥7.0,uiviewcontroller.view.bounds.height contains the standard system status bar height and navigation bar height, but does not include the Hotspot bar, if any.

That is, when there is a hotspot bar, UIViewController.view.bounds.height automatically deducted the height of the hotspot bar , ios<7.0 does not include the standard system status bar, ios≥7.0 contains the standard system status bar.
Since iOS7 takes the entire screen height (including the status bar, excluding the hotspot bar) as the effective height of the view controller, when upgrading from IOS6 to IOS7, the view moves up the height of a status bar as a whole (20pt) and overlaps with the upper status bar.

The above two paragraphs are borrowed they summed up some of the explanatory things, the analysis is also very detailed, the principle is to understand, after encountering problems must learn to summarize, otherwise too easy to forget. Online gave some ideas to solve, I refer to the more good two blog, they give the idea is very good, but also need to add some processing and judgment, let me say the whole process of solving the problem. Normal hot spots caused by the position of the status bar adjustment there are two cases, one is that the current page has been created open, another situation is that the page has not been created, the following to specifically distinguish.

1, the status bar change notification processing and addingUIApplicationWillChangeStatusBarFrameNotification,UIApplicationDidChangeStatusBarFrameNotification是状态栏变化会走的两个通知,可以在

-(void) Viewwillappear: (BOOL) animated

{

[Super viewwillappear:animated];

[Self.navigationController.navigationBar Sethidden:yes];

[[Nsnotificationcenter Defaultcenter] addobserver:self selector: @selector (statusbarframewillchange:) name:uiappli Cationwillchangestatusbarframenotification Object:nil];

[[Nsnotificationcenter Defaultcenter] addobserver:self selector: @selector (layoutcontrollersubviews:) name:uiappli Cationdidchangestatusbarframenotification Object:nil];

CGRect statusbarrect = [[UIApplication sharedapplication] statusbarframe];

if (statusBarRect.size.height = = 40)

{

[MyTable setframe:cgrectmake (0, -20, ui_view_hieght+64-58)];

[Bottomview Setframe:cgrectmake (0,ui_view_hieght+64-58-20,320, 58)];

}

Else

{

[MyTable setframe:cgrectmake (0, 0, ui_view_hieght+64-58)];

[Bottomview Setframe:cgrectmake (0,ui_view_hieght+64-58,320, 58)];

}

}

After repeated testing found that the original notification will only be opened in the page has been created to go, so you need to register to monitor the status bar notification, and for processing

#pragma mark-status bar recording or call status notification

-(void) Layoutcontrollersubviews: (nsnotification *) notification

{

[UIApplication sharedapplication].statusbarframe.size.height=20;

CGRect statusbarrect = [[UIApplication sharedapplication] statusbarframe];

if (statusBarRect.size.height = = 40)

{

[MyTable setframe:cgrectmake (0, -20, ui_view_hieght+64-58)];

[Bottomview Setframe:cgrectmake (0,ui_view_hieght+64-58-20,320, 58)];

}

Else

{

[MyTable setframe:cgrectmake (0, 0, ui_view_hieght+64-58)];

[Bottomview Setframe:cgrectmake (0,ui_view_hieght+64-58,320, 58)];

}

}

-(void) Statusbarframewillchange: (nsnotification*) notification

{

[Self HideTabbar:self.statusBarHidden animated:yes];

[[UIApplication sharedapplication] setstatusbarhidden:yes];

CGRect statusbarrect = [[UIApplication sharedapplication] statusbarframe];

if (statusBarRect.size.height = = 40)

{

[MyTable setframe:cgrectmake (0, -20, ui_view_hieght+64-58)];

[Bottomview Setframe:cgrectmake (0,ui_view_hieght+64-58-20,320, 58)];

}

Else

{

[MyTable setframe:cgrectmake (0, 0, ui_view_hieght+64-58)];

[Bottomview Setframe:cgrectmake (0,ui_view_hieght+64-58,320, 58)];

}

}

Another situation is that the page has not been opened before the hotspot has been connected, so that the opening of the page is not going to notice where, need to

-(void) Viewwillappear: (BOOL) animated plus the above processing, and the notice inside the code is the same, two are necessary, so that after repeated testing the effect is still good, today said here first, thinking finally clear also.

Iphone/ios to open the relevant position adjustment summary of personal hotspot

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.