Iphone/ios a summary of vertical adaptation of personal hotspot opening

Source: Internet
Author: User

I. iphone create personal hotspotIphone/ios dual-loop internet , the IPhone enables shared Internet access by creating personal hotspots (Personal hotspot), supporting portable Wi-Fi hotspots, Bluetooth shared networks, and USB shared networks.
1. If the iphone has turned on wifi (and Bluetooth), the direct creation is successful.

Other devices can search for hotspot names via WiFi (or Bluetooth) and connect to share the Internet.

What to note is: Apple's Bluetooth protocol is closed, only support the Apple device (IPHONE/IPAD/IMAC) between the connection, not with Android and other devices such as Bluetooth to find pairing!
2. If the iphone only turns on Bluetooth and no wifi is turned on, the prompt


If you select Turn on Wi-Fi (Turn on Wi-Fi), other devices can search for the hotspot name via WiFi and connect to share the Internet.

If you select Bluetooth and USB only (Bluetooth and USB only), other devices can connect to the iphone search hotspot name via Bluetooth or USB and connect for shared Internet access.
3. If the iphone does not turn on Bluetooth and WiFi, prompt


If you select Turn on Wi-Fi and Bluetooth (Turn on Wi-Fi and bluetooth®), other devices can search for the hotspot name via Bluetooth/wifi and connect to share the Internet.

If you select USB only, other devices can connect to the iphone search hotspot name via USB and connect for shared Internet access.


two. imac via USB Connect iphone share personal hotspot Internet

When the iphone creates a new personal hotspot, theiMac (Mac OS X) connects to the iphone via USB and automatically connects to the iphone's personal hotspot (the first 1 Connection).


When debugging an iphone on a mac/xcode, if you only want to debug a situation where your iphone/android is connected to a personal hotspot (so that you can test for hot spots and no hotspot bars), Network Preferences deleted in IPhone USB interface (interface) To prevent the Mac from automatically connecting to the iphone hotspot via USB to interfere with debugging.


three. Iphone/ios personal hotspot status bariphone 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, containing the height of the hotspot bar (if any).

iOS system version

#definesystem_version    [[[Uidevice Currentdevice] systemversion] doublevalue]

Standard system Status Bar height

#defineSys_statusbar_height        20
//hotspot Bar Height
#defineHotspot_statusbar_height20
//navigation bar (uinavigationcontroller.uinavigationbar) Height
#defineNavigationbar_height44
//toolbar (uinavigationcontroller.uitoolbar) Height
#defineToolbar_height        44
//tab bar (uitabbarcontroller.uitabbar) Height
#defineTabbar_height        44
//App_statusbar_height=sys_statusbar_height+[hotspot_statusbar_height]
#defineApp_statusbar_height(Cgrectgetheight ([uiapplication sharedapplication].statusbarframe))
//Based on app_statusbar_height to determine if there is a hotspot bar
#defineis_hotspot_connected(app_statusbar_height== (sys_statusbar_height+hotspot_statusbar_height)? Yes:no)
//No hotspot bar, standard system status bar height + navigation bar height
#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).
    • 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).
When there is a hotspot bar, UIViewController.view.bounds.heightautomatically deducts the height of the hotspot bar, ios<7.0 does not contain 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.
Workaround: SetExtendedlayoutincludesopaquebarsproperty is no, setEdgesforextendedlayoutFor Uirectedgenone.


3.UIViewController Adaptation hotspot Bar sample code

-(void)Viewwillappear:(BOOL) animated
{
Self.extendedlayoutincludesopaquebars = NO;
Self.edgesforextendedlayout = Uirectedgenone;
}

//Myviewcontroller interface inherits from Uiviewcontroller
@interfaceMyviewcontroller: Uiviewcontroller

//myviewcontroller* myviewcontroller into the stack
myviewcontroller* Myviewcontroller = [[Myviewcontroller alloc] init];
[Self.navigationcontroller Pushviewcontroller:myviewcontroller Animated:yes];

-(ID)Init
{
//Initial non-fullscreen
_bfullscreen = NO;
//status before entering the Uiviewcontroller
_laststatusbarstyle = [[UIApplication sharedapplication] statusbarstyle];
_lastbartranslucent = self.navigationController.navigationBar.translucent;
}

-(void)Viewwillappear:(BOOL) animated
{
[Super viewwillappear:animated];

if (_bfullscreen)
{
if (system_version >= 7.0)
{
Self.extendedlayoutincludesopaquebars = YES;
Self.edgesforextendedlayout = Uirectedgeall;
}
Else
{
Self.wantsfullscreenlayout = YES;
Self.navigationController.navigationBar.translucent = YES; Keep navigation bar transparent under IOS 6
}
}
Else
{
[[UIApplication sharedapplication] setstatusbarstyle:_laststatusbarstyle];
if (system_version >= 7.0)
{
//Set: When there is a personal hotspot connection, the Uiviewcontroller.view automatically moves down 20; when there is no personal hotspot connection, the Uiviewcontroller.view automatically moves up
Self.extendedlayoutincludesopaquebars = NO;
Self.edgesforextendedlayout = Uirectedgenone;
}
Else
{
Self.wantsfullscreenlayout = NO;
Self.navigationController.navigationBar.translucent = _lastbartranslucent;
}
}
}

//Manually tap the content area for full screen
-(void)Setfullscreen:(BOOL) bfull
{
_bfullscreen = bfull;

//Full screen (not full screen) hide (display) system status bar
[[UIApplication sharedapplication] setstatusbarhidden:bfullscreen];
//Full screen (not fullscreen) hide (show) top navigation bar
[Self.navigationcontroller Setnavigationbarhidden:bfullscreen Animated:yes];
//Full screen (not fullscreen) hide (show) Bottom toolbar
[Self.navigationcontroller Settoolbarhidden:bfullscreen Animated:yes];

//The Rect of the custom content is calculated below
if (!_supportfullscreen)
{
CGFloat contentsatrty = 0;

if (is_hotspot_connected) {//IPhone4 (s)-ios6/ios7 screen coordinate system: HOSTVIEW.FRAME={{0, Max}, {[+], 440}}/{{0, +}, {+, 460}}
Contentsatrty = Status_and_nav_bar_height;//
if (system_version >= 7.0) {//If the Edgesforextendedlayout=uirectedgenone is set
Contentsatrty-= Hotspot_statusbar_height;//64 (will automatically move down when a hotspot bar is available)
}
} else {//IPhone4 (s)-ios6/ios7 screen coordinate system: hostview.frame={{0, + {, 460}}/{{0, 0}, {(+), 480}}
Contentsatrty = Normal_status_and_nav_bar_height;//
}

//Contentsatrty layout based on the screen coordinate system where Uiviewcontroller.view is located
Contentrect = CGRectMake (0, Contentsatrty, Hostview.width, screen_height-status_and_nav_bar_height-toolbar_height);
}
Else//For IOS6/7 respectively configured Wantsfullscreenlayout=yes/edgesforextendedlayout=uirectedgeall, full-screen hide status bar (including Hotspot bar), The height of the navigation bar and toolbar is screen_height.
{
Contentrect = CGRectMake (0, 0, hostview.width, hostview.height);
}

}


#pragma Mark Uiapplicationwillchangestatusbarframenotification
//If necessary, monitor the system status bar change notification:
uiapplicationwillchangestatusbarframenotification

-(void)handleuiapplicationwillchangestatusbarframenotification:(nsnotification*) notification
{
CGRect newstatusbarframe = [(nsvalue*) [Notification.userinfo objectforkey: Uiapplicationstatusbarframeuserinfokey] Cgrectvalue];

//According to the system status bar to determine the change in the hotspot bar
    BOOL bpersonalhotspotconnected = (cgrectgetheight (newstatusbarframe) = = (Sys_statusbar_height+hotspot_statusbar_ HEIGHT)? Yes:no);

    Cgpoint newcenter = Cgpointzero;
CGFloat OffsetY = bpersonalhotspotconnected?+hotspot_statusbar_height:-hotspot_statusbar_height;
if (system_version >= 7.0) {//Make necessary manual adjustments to some two-level, three-level sub-view without automatic adjustment
Newcenter = Self.someSubView.center;
Newcenter.y + = OffsetY;
Self.someSubView.center = Newcenter;
} else {//Custom content corresponding view overall adjustment
Newcenter = Self.contentView.center;
Newcenter.y + = OffsetY;
Self.contentView.center = Newcenter;//Contentview is the custom content corresponding view
}
}

@end



Iphone/ios a summary of vertical adaptation of personal hotspot opening

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.