ios6-7以後使用者開熱點後的螢幕適配

來源:互聯網
上載者:User

標籤:

// 排版時,注意logical coordinate space和device coordinate space的區別,注意frame和bounds的區別!

 

- (void)loadView

{

    // ...

 

    // 計算Custom Content View的Rect
    if (!_supportFullScreen)
    {
        CGFloat contentSatrtY = 0;
        
        if (IS_HOTSPOT_CONNECTED) { // iPhone4(s)-iOS6/iOS7螢幕座標系下:hostView.frame={{0, 40}, {320, 440}}/{{0, 20}, {320, 460}}
            contentSatrtY = STATUS_AND_NAV_BAR_HEIGHT; // 84
            if (SYSTEM_VERSION >= 7.0) { // 如果設定了edgesForExtendedLayout=UIRectEdgeNone
                contentSatrtY -= HOTSPOT_STATUSBAR_HEIGHT;// 64(有熱點欄時,會自動下移20)
            }
        } else { // iPhone4(s)-iOS6/iOS7螢幕座標系下:hostView.frame={{0, 20}, {320, 460}}/{{0, 0}, {320, 480}}
            contentSatrtY = NORMAL_STATUS_AND_NAV_BAR_HEIGHT; // 64
        }
        
        // contentSatrtY基於UIViewController.view所在的螢幕座標系進行排版
        contentRect = CGRectMake(0, contentSatrtY, hostView.width, SCREEN_HEIGHT-STATUS_AND_NAV_BAR_HEIGHT-TOOLBAR_HEIGHT);
    }
    else // 針對iOS6/7分別配置了wantsFullScreenLayout=YES/edgesForExtendedLayout=UIRectEdgeAll,全屏隱藏狀態列(包括熱點欄)、導覽列和工具列之後高度為SCREEN_HEIGHT。
    {
        contentRect = CGRectMake(0, 0, hostView.width, hostView.height);
    }

 

    // ...

}

// 如有必要,需監聽系統狀態列變更通知:UIApplicationWillChangeStatusBarFrameNotification

- (void)handleUIApplicationWillChangeStatusBarFrameNotification:(NSNotification*)notification
{
    CGRect newStatusBarFrame = [(NSValue*)[notification.userInfo objectForKey:UIApplicationStatusBarFrameUserInfoKey] CGRectValue];

    // 根據系統狀態列高判斷熱點欄的變動
    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) { // 即使設定了extendedLayoutIncludesOpaqueBars=NO/edgesForExtendedLayout=UIRectEdgeNone,對沒有自動調整的部分View做必要的手動調整
        newCenter = self.someSubView.center;
        newCenter.y += OffsetY;
        self.someSubView.center = newCenter;
    } else { // Custom Content對應的view整體調整
        newCenter = self.contentView.center;
        newCenter.y += OffsetY;
        self.contentView.center = newCenter; // contentView為Custom Content對應的view
    }
}

@end

 

 

.iPhone/iOS個人熱點的interface

iPhone開啟個人熱點(橋接上網)時,會多出bridge介面。

 

iPhone5s/iOS8.2開啟個人熱點時,遍曆可發現多出3個活躍的bridge100介面(IFF_UP),sa_family分別是AF_LINK(18)、AF_INET6(30)、AF_INET(2)。

遍曆interface的程式碼片段如下:

 

struct ifaddrs *interfaces = nil;

 

if(!getifaddrs(&interfaces))

 

{

 

    for(structifaddrs *interface = interfaces; interface; interface = interface->ifa_next) {

 

            if ((interface->ifa_flags&IFF_UP) ==IFF_UP) {

 

                log_notice("ifa_name : %s, ifa_addr->sa_family : %d", interface->ifa_name, interface->ifa_addr->sa_family);

 

            }

 

       }

 

}

 

 

 

if (interfaces) {

 

    freeifaddrs(interfaces);

 

    interfaces = NULL;

 

}

ios6-7以後使用者開熱點後的螢幕適配

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.